2

I would like to use the Dojo Data Grid/REST service architecture in an application I am building. However, I cannot find the property (or code) to have the REST service point to a view in another application outside the current one.

Can I use a Data Context in the view name of the REST Service? Or is there another property to set to point to a view in another application?

Thanks -- appreciate your help!

--------- EDIT 6/24/2013 ---------

I have tried both the viewItemFileService and viewJSONService and I can only get the viewJSONService to work with the other database. The viewItemFileService just displays "Sorry, an error has occurred" where the rows of data should be. Here is the code -- I am not sure where I am making the mistake:

            <xp:panel>
                View JSON<xp:br></xp:br>
                <xe:restService id="restService1">
                    <xe:this.service>
                        <xe:viewJsonService databaseName="voca/vocadatastore.nsf"
                            defaultColumns="true" viewName="InvoicePersonnel" var="entry1"
                            contentType="application/json">
                        </xe:viewJsonService>
                    </xe:this.service>
                </xe:restService>
                <xe:djxDataGrid id="djxDataGrid2" autoHeight="10"
                    storeComponentId="restService1">
                    <xe:djxDataGridColumn id="djxDataGridColumn5"
                        label="Description" field="description" width="auto">
                    </xe:djxDataGridColumn>
                    <xe:djxDataGridColumn id="djxDataGridColumn6"
                        label="Items" field="items" width="auto">
                    </xe:djxDataGridColumn>
                    <xe:djxDataGridColumn id="djxDataGridColumn7"
                        label="Cost" field="cost" width="auto">
                    </xe:djxDataGridColumn>
                    <xe:djxDataGridColumn id="djxDataGridColumn8"
                        label="Total" field="total" width="auto">
                    </xe:djxDataGridColumn>
                </xe:djxDataGrid>
            </xp:panel>
            <xp:br></xp:br>
            <xp:br></xp:br>
            <xp:panel>View Domino<xp:br></xp:br>
                <xe:restService id="restServicePers">
                    <xe:this.service>
                        <xe:viewItemFileService databaseName="voca/vocadatastore.nsf"
                            defaultColumns="true" viewName="InvoicePersonnel" var="entry2">
                        </xe:viewItemFileService>
                    </xe:this.service>
                </xe:restService>
                <xe:djxDataGrid id="djxDataGrid1" autoHeight="10"
                    storeComponentId="restServicePers">
                    <xe:djxDataGridColumn id="djxDataGridColumn1"
                        label="Description" field="description" width="auto">
                    </xe:djxDataGridColumn>
                    <xe:djxDataGridColumn id="djxDataGridColumn2"
                        label="Items" field="items" width="auto">
                    </xe:djxDataGridColumn>
                    <xe:djxDataGridColumn id="djxDataGridColumn3"
                        label="Cost" field="cost" width="auto">
                    </xe:djxDataGridColumn>
                    <xe:djxDataGridColumn id="djxDataGridColumn4"
                        label="Total" field="total" width="auto">
                    </xe:djxDataGridColumn>
                </xe:djxDataGrid>
            </xp:panel>

--------- EDIT 7/3/2013 ---------

I moved the view to the same database as the REST service and still received "Sorry, an error occurred" message. The view name is correct since I selected the viewName from the list. The column title/field name is correct also.

<xe:restService id="restServicePers" pathInfo="persInfo">
                            <xe:this.service>
                                <xe:viewItemFileService defaultColumns="true"
                                    viewName="InvoicePersonnel" var="entryPers">
                                </xe:viewItemFileService>
                            </xe:this.service>
                        </xe:restService>
                        <xe:djxDataGrid id="djxDataGrid1" autoHeight="10"
                            storeComponentId="restServicePers">
                            <xe:djxDataGridColumn id="djxDataGridColumn1"
                                label="Description" field="description" width="auto">
                            </xe:djxDataGridColumn>
                        </xe:djxDataGrid>

I added the pathInfo property to the REST service to see what is being returned and there was an error:

{
    "code":500,
    "text":"Internal Error",
    "message":"",
    "type":"text",
    "data":"java.lang.NullPointerException\r\n\tat com.ibm.domino.services.rest.das.view.RestViewNavigatorFactory$ViewNavigatorNavigator.getTopLevelEntryCount(RestViewNavigatorFactory.java:565)\r\n\tat com.ibm.domino.services.rest.das.view.RestViewItemFileService.renderServiceJSONGet(RestViewItemFileService.java:263)\r\n\tat com.ibm.domino.services.rest.das.view.RestViewItemFileService.renderService(RestViewItemFileService.java:77)\r\n\tat com.ibm.domino.services.HttpServiceEngine.processRequest(HttpServiceEngine.java:167)\r\n\tat com.ibm.xsp.extlib.component.rest.UIBaseRestService._processAjaxRequest(UIBaseRestService.java:242)\r\n\tat com.ibm.xsp.extlib.component.rest.UIBaseRestService.processAjaxRequest(UIBaseRestService.java:219)\r\n\tat com.ibm.xsp.util.AjaxUtilEx.renderAjaxPartialLifecycle(AjaxUtilEx.java:206)\r\n\tat com.ibm.xsp.webapp.FacesServletEx.renderAjaxPartial(FacesServletEx.java:225)\r\n\tat com.ibm.xsp.webapp.FacesServletEx.serviceView(FacesServletEx.java:170)\r\n\tat com.ibm.xsp.webapp.FacesServlet.service(FacesServlet.java:160)\r\n\tat com.ibm.xsp.webapp.FacesServletEx.service(FacesServletEx.java:138)\r\n\tat com.ibm.xsp.webapp.DesignerFacesServlet.service(DesignerFacesServlet.java:103)\r\n\tat com.ibm.designer.runtime.domino.adapter.ComponentModule.invokeServlet(ComponentModule.java:583)\r\n\tat com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(NSFComponentModule.java:1281)\r\n\tat com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(ComponentModule.java:854)\r\n\tat com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(ComponentModule.java:751)\r\n\tat com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(ComponentModule.java:572)\r\n\tat com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(NSFComponentModule.java:1265)\r\n\tat com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(NSFService.java:658)\r\n\tat com.ibm.domino.xsp.module.nsf.NSFService.doService(NSFService.java:481)\r\n\tat com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:341)\r\n\tat com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:297)\r\n\tat com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272)\r\n"
}
Dan
  • 940
  • 2
  • 14
  • 42
  • I would assume you could use datacontext. Give it a try! – David Navarre Jun 21 '13 at 21:25
  • Your example worked for me (after adapting db, view and field names). I discovered a different behavior between viewItemFileService and viewJSONService though. If one of the field names `field="xxx"` is not valid then viewJSONService still works but not so viewItemFileService. Maybe one of your field names is not valid (= not definied in view)? – Knut Herrmann Jun 25 '13 at 21:26
  • The field name has to match to column name in view. Column name is defined in last tab of column property dialog box at "Programmatic Use: / Name:" – Knut Herrmann Jun 26 '13 at 09:08
  • Could you get it to run? – Knut Herrmann Jun 28 '13 at 16:05
  • @Knut -- I tried rebuilding the view and even moved the view into the same database --- I edited the main post above. Still receiving an error. – Dan Jul 03 '13 at 16:04
  • I think your view is categorized. I tried it with a categorized view and I got same error. Without view being categorized it worked well. So, choose a view without category **or** define a `keys` property in `xe:restService/service/viewItemFileService/keys="yourKey"`. `keys` should contain one or more values of your categorized column. Please let me know if it works for you now. – Knut Herrmann Jul 03 '13 at 18:16
  • For the keys property, I have <![CDATA[#{javascript:document1.getItemValueString("id");}]]> -- is this correct? When I remove the categorized column it works, however, when I try the keys above I get that same error. – Dan Jul 08 '13 at 18:55
  • 2
    Hey, we are close to solve your viewItemFileService issues :) - Yes, keys javascript code looks good. I assume your view has only one categorized column and contains id only. Please try a key with a real id from your categorized column like `<![CDATA[#{javascript:"586456388"}]]>`. That should work. Try from there to figure out how to set a proper value for keys. Please let me know if it works - please add @Knut to your comment so that I get notified. Thanks – Knut Herrmann Jul 10 '13 at 06:41
  • @Knut, I was having the same problem, and your advice buried in these comments fixed my problem. The solution is to that ViewItemFileService won't work with categorized columns, and to use the Keys instead to act like a category. Thank You! – Steve Zavocki Jul 22 '13 at 17:56
  • @Knut, Correction, it does work with categorized columns, but it does not work with Category Filter, you must use keys. – Steve Zavocki Jul 22 '13 at 18:17
  • @Dan, did it finally work for you? Steve wanted to know that too: http://notesspeak.blogspot.com/2013/07/creating-updatable-rest-service-for-use.html - BTW, please consider to vote up answers if they were helpful to you - you've never did this for your 12 questions so far. – Knut Herrmann Jul 25 '13 at 21:47
  • @Knut - I still have not got this to work. Steve - I did not abandon my question - I am still working on it with no solution. – Dan Sep 18 '13 at 20:08

1 Answers1

5

There is a property databaseName in service definitions

  • xe:viewItemFileService
  • xe:viewJsonLegacyService
  • xe:viewJsonService
  • xe:viewXmlLegacyService

in xe:restService.

If it's empty then the current database is used but if you put in path and name of a database then those database is used.

The view name is defined in property viewName.

        <xe:restService id="restService1">
            <xe:this.service>
                <xe:viewItemFileService
                    databaseName="MyFolder/MyOtherDatabase.nsf"
                    viewName="AllContacts"
                    ...>
Knut Herrmann
  • 30,880
  • 4
  • 31
  • 67
  • Pro Tip: use the replicaid instead of the file name, insured against databases beeing moved around – stwissel Jun 24 '13 at 00:43
  • Best practice is to put the database path/name or replicaId in a properties file or configuration document and "calculate" the value for `databaseName` – Knut Herrmann Jun 24 '13 at 05:14