Search code examples
xpagesdojox.grid.datagridjsonreststore

Xpages: Can you build a Dojo Data Grid with a with a Rest service in a separate XPage?


I have created an Xpage with only one element, a JSON Rest service that points to a view (I guess I should probably put this in a CC).

I want to build another Xpage with a CC that contains a CC that contains a Dojo Data Grid that points to this rest service.

How can I do that? It seems to me that I should separate out my calls to the data from the interface. I am surprised that this is not easier to do.


Solution

  • Put your REST service in a CC and include it into your Dojo Data Grid control XPages/CC.

    <xp:include
           id="restService"
           pageName="restServiceCC.xsp" />
    

    Don't forget to add ".xsp" to the name of your CC.

    Update

    To use include is the (only) way to separate the Dojo Data Grid control and the REST service in separate XPages/CC as you asked in your question.

    As REST services can be separate design elements this way you can define all REST services in a template database and let the applications inherit from there. REST services itself can provide data from any database/view.

    The Dojo Data Grid control is the easiest way to include Data Grids to your applications but it needs the REST service to be in the database itself.

    As an alternative you can use a "pure" Data Grid based on client side JavaScript. Data Grids get their data usually from an URL per Ajax. This would give you the possibility to put all REST services in one database. You have much more flexibility with this approach than using the Dojo Data Grid control. But, be aware that it needs some days to get into it. I use the free jqGrid based on jQuery as the "pure" Data Grid. You can find more information about it in my presentation at EntwicklerCamp 2014 (sorry, its in German - Google translator is your friend) including a comparison with Dojo Data Grid and ExtJs Grid.