Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Handling rest datasource from existing service

    Hello, i'm investigating using a restdatasource in my client code, and i have a few questions i'm really hoping you can help me with.

    1. EXISTING REST SERVICE
    I've read your documentation re. restdatasource and how you expect the json to be formatted (here: https://www.smartclient.com/smartgwt...ataSource.html)

    However, i am going to connect to services using spring mvc using slice etc. and their stucture is this:

    data itself is in a root "content"-node.
    metadata looks like:
    Code:
    "numberOfElements": 3,  
    "first": true,  
    "last": false,  
    "sort": null,  
    "size": 3,  
    "number": 0
    If i cannot alter this, what is your recommended approach to using these json structures in databound smartgwt components? Some transformer (client/serverside)? Where do i put it?


    2. LOADING DATASOURCES
    I have a bunch of smartgwt-specific datasources as well, defined in xml, downloaded on startup, calling spring services. Is it possible to also define restdatasources in xml, and have them downloaded the same way? The usecase here is to have all datasources defined in the same place and in the same way. This would be beneficial for i18n, validation etc. If not, ok, just thought i'd ask.


    Thoughts appreciated.

    #2
    1. The point of RestDataSource is that it provides a fully-spec'd protocol that handles all the features expected by our advanced components (such as grids submitting multiple edited rows as a transaction). If you are forced to adapt to a pre-existing protocol, start with DataSource (this is covered in the RestDataSource docs and QuickStart Guide, Data Integration chapter).

    However, we generally recommend just implementing server-side handling for the RestDataSource protocol, which is easy enough (we've done it in 6-7 languages by now). It is often more work to "dumb down" our components to be compatible with a simpler protocol that it is to simply implement server support for the RestDataSource protocol. Also, if you dumb down the UI, then the result is of course a worse one.


    2. Yes, you can use XML to define a RestDataSource, or other DataSource that is used only client-side and has no server-side behavior. It's the dataSource.serverType setting that will cause the server to actually do something with dsRequests against the DS - with the default of "generic", requests will just be rejected if you have not defined any server logic via operationBindings.

    Comment


      #3
      Thanks for great responses. The service i'm looking at can't probably be changed, unfortunately. A first for me :) I'll check the data integration chapter.

      Comment

      Working...
      X