With server-side datasources, you can specify the information contained in the datasource using .xml files. The datasource is automatically created with the fields defined in the .xml file.
I need a restful datasource which is client-side. Will SmartGWT generate the code necessary to generate a datasource from XML when the datasource runs on the client side?
Yes, this can be done - load the DataSource normally using the DataSourceLoader servlet, and use _constructor="RestDataSource" on the <DataSource> tag to cause a RestDataSource to be created in the browser. Any given method call on RestDataSource translates to a same-named property in XML by the Java Beans convention (setBlah("value") -> blah="value").
However the question is - what for? Just trying to make sure you're not doing unnecessary work, it's hard to image why you would do this.
If you want third-party applications to have access to your DataSource operations, this is automatic, no effort required - see the RestHandler discussion in the Server Framework chapter.
If you want to access pre-existing Rest services hosted elsewhere within your company, there is no need to *both* create a server-side DataSource and client-side DataSource. Just create the client-side DataSource.
If I use the RestDataSource + RestHandler do I get the
nice integration of filtering, sorting, etc?
If I bind a ListGrid to a RestDataSource connected to
a RestHandler, can I use the sorting facilities in ListGrid?
This would be great in that we could have one service
that could function as the SmartGWT gui backend and
also allow automated connection by third parties for
data mining.....
Yes, it would work to create a RestDataSource to talk to the RestHandler. Don't do this. Continue using DataSources based on .ds.xml files exactly as described in the QuickStart Guide and other materials.
The purpose of the RestHandler is for third party technology to talk to the DataSources you've defined via .ds.xml files, using the same XML or JS *message format* as the RestDataSource, but not using the RestDataSource class itself (since we're talking about third-party non-SmartGWT technology).
In a nutshell, just by using the system as described in the QuickStart Guide, you are already done with what you wanted to do (provide a REST interface for third parties).
There's no example code (it wouldn't be a SmartGWT example) but there are example messages / URLs, since the RestDataSource class explains the protocol. For a simple test, put together a URL to the RestHandler servlet with appropriate parameters and just paste it into the address bar of an ordinary web browser.
Comment