I'm a newbie in with this. Can someone help me how can I understand REST data sources like how it works, how it is made and how it connects with the database, how it works in JSON and XML.
THANKS!
I'm a newbie in with this. Can someone help me how can I understand REST data sources like how it works, how it is made and how it connects with the database, how it works in JSON and XML.
THANKS!
Ok, so with LGPL edition you don't have any server side binding that is provided for you by default, therefore you need to create you own DataSource implementation from the scratch. This is a draft concept that you can go with:
Create com.smartgwt.client.data.RestDataSource on client side. This is some basic setup that I'm using:
setDataURL("/core/restds");
setDataFormat(DSDataFormat.JSON);
setDataProtocol(DSProtocol.POSTMESSAGE);
OperationBinding fetchOperation = new OperationBinding();
fetchOperation.setOperationType(DSOperationType.FETCH);
fetchOperation.setDataProtocol(DSProtocol.POSTMESSAGE);
setOperationBindings(fetchOperation);
// define datasource fields
addField(..)
On the server side I'm declaring servlet:
<servlet-mapping>
<servlet-name>restDSServlet</servlet-name>
<url-pattern>/core/restds</url-pattern>
</servlet-mapping>
In this servlet I'm using jackson library to parse JSON request and to pretare JSON responses. You can also use XML data format, but it is more verbose.
Last step is binding dataSource with SmartGWT UI component:
component.setDataSource(...)
This is all that I can tell you right now. Please have in mind that paid versions of SmartGWT have integration with most popular persistence mechanisms, so the question is do you want to pay for ready solution or write your own.