• xe:documentJsonService and adding items

    By Thomas Adrian 1 decade ago

    I have added a documentJsonService to an xpages but I can't get the items from the documets to display in the output.

    Is this a bug or am I doing something wrong

     

     

    <?xml version="1.0" encoding="UTF-8"?>
    
    <xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xe="http://www.ibm.com/xsp/coreex">
    
    <xe:restService id="restService4" pathInfo="test2" state="true">
    
    <xe:this.service>
    
    <xe:documentJsonService formName="Post" defaultItems="true" contentType="application/json">
    
    <xe:this.items>
    
    <xe:restDocumentItem itemName="Form" name="Form"></xe:restDocumentItem>
    
    </xe:this.items>
    
    <xe:this.search><![CDATA[FIELD FORM = "Post"]]></xe:this.search>
    
    </xe:documentJsonService>
    
    </xe:this.service>
    
    </xe:restService>
    
    </xp:view>
    
     
    

    This is the output

     

     

    {
          "@modified":"2011-12-08T15:18:30Z",
          "@unid":"BD3083C923CD55ACC12578080040E190",
          "@href":"...."
      },

     

    • REST service control properties?

      By Dave Delay 1 decade ago

      My guess is you need to change some properties on the REST service control.  For example, the REST_DataService page in the sample database has this mark-up:

       

                                  pathInfo="documentPathInfo">
                      
                          
                      

                  

       

      That produces a response with all the document items.  Maybe you shouldn't be setting the items property?

       

      In any case, this is not my area.  I will forward this to the developer who knows the code.

       

      Thanks.

       

      -- Dave

    • Set defaultItems to true...

      By Stephen Auriemma 1 decade ago

      For the documentJsonService to get the item data you need to set property defaultItems to true.  For the viewJsonService to get the column data you need to set property defaultColums to true. I frequently forget to set these properties myself. Maybe we should consider a default value of true?

      Steve

      • have you tried it? I could not get it to work

        By Thomas Adrian 1 decade ago

        have you tried it? I could not get it to work even if I enable the defaultitems

         

        I am using the documentJsonService

        also, what is the documentJsonService returning, it looks like it is all documents in the database?

         

        Thanks

        Thomas

        • You are requesting a list of documents

          By Dave Delay 1 decade ago

          Thomas,

           

          The documentJsonService can be used to get a list of documents or a single document.  It depends on URL you specify.  There are examples of this in the REST_DataService page of the sample database.  For example, this URL gets a single document:

           

          http:///XPagesExt.nsf/REST_DataService.xsp/documentPathInfo/unid/

           

          This URL gets a list of documents:

           

          http:///XPagesExt.nsf/REST_DataService.xsp/documentPathInfo

           

          When you ask for a list of documents, the service just returns a bit of summary data for each document.  To get all the document items, you have to request a single document by UNID as shown in the first URL above.

           

          -- Dave

          • so,how can I get a list of documents as JSON

            By Thomas Adrian 1 decade ago

            Thanks for the info

            so is there an easy way to use the REST controls to return a list of documents as JSON with items from a document that I have specified.

            I do not want to use views to get the data.

             

             

            Thanks

            Thomas

            • Sorry but no ...

              By Dave Delay 1 decade ago

              The REST services work just like the underlying Notes/ Domino APIs.  Documents contain summary and non-summary items.  You can build views that select certain documents from the database and contain summary data (and computed values) for each row.  You can read the summary data from a view, but you must open a document to read all the items. 

               

              I guess I don't understand your use case.  Why don't you want to build a view to read the document data?  Also, if you aren't using a view, how do you find the documents you are looking for?

               

              -- Dave

              • ok

                By Thomas Adrian 1 decade ago

                OK Dave.

                thanks for your info.

                I know it may sound strange to not use columns.

                Actually I have several views in my database, but they all have only one column which I use for lookups, all documents have list keys which is used in the column.

                I do not want to start creating a lot views with columns in order to show specific features in my xpages. then I will soon have too many views in the database and will end up with poor performance.

                http://www.intrapages.com

                 

                Thanks for your time

                Thomas

                 

                 

                • There are tradeoffs ...

                  By Dave Delay 1 decade ago

                  Having lots of columns in a view can be somewhat expensive, but the underlying view code is highly optimized.  By comparison it is much more expensive to open a document repeatedly.  That's why the documentJsonService doesn't open each document as it is building a list.

                   

                  It sounds like you understand the tradeoffs.  Maybe you can use the viewJsonService to find a document by key and then use the documentJsonService to read the document by UNID.

                   

                  Best of luck!

                   

                  -- Dave

            • This sounds like a feature request.

              By Stephen Auriemma 1 decade ago

              > Is there an easy way to use the REST controls to return a list of documents as JSON with items from a document?

              We have considered adding a batch GET request that would allow you to send a list of document unids and return the documents as a list in one response. Would this feature meet your requirements.

              • maybe

                By Thomas Adrian 1 decade ago

                ok, I may not have the whole picture,

                My need is to display entries in a DWA calendar from document data (not view data)

                maybe there is another way to display the entries in the calendar, than using JSON or maybe there is another way to get a collection of documents as JSON.

                 

                Thanks

                Thomas