While creating a simple client for a REST service which I have stubbed out, I noticed that smartGWT's RestDataSource class is limited in the type of xml it can understand. All REST resources must respond with XML in the following format..
<response>
<status>0</status>
<startRow>0</startRow>
<endRow>10</endRow>
<totalRows>50</totalRows>
<data>
<record>
<someField>value</someField>
<someOtherField>value</someOtherField>
</record>
<record>
<someField>value</someField>
<someOtherField>value</someOtherField>
</record>
...
</data>
</response>
.. where the only variant is the someField/someOtherField tags.
This structure, which is little more than name/value pairs, is not going to work for us.
I then saw this demo on the SmartGWT showcase...
http://www.smartclient.com/smartgwtee/showcase/#data_integration_server_rss
Which shows how to consume xml in an arbitrary format for display like so...
package com.smartgwt.sample.showcase.client.webservice;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.data.fields.DataSourceLinkField;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.sample.showcase.client.PanelFactory;
import com.smartgwt.sample.showcase.client.ShowcasePanel;
public class RssSample implements EntryPoint {
public void onModuleLoad() {
DataSource dataSource = new DataSource();
dataSource.setDataURL("http://rss.slashdot.org/Slashdot/slashdot");
dataSource.setRecordXPath("//default:item");
DataSourceTextField titleField = new DataSourceTextField("title", "Title");
DataSourceLinkField linkField = new DataSourceLinkField("link", "Link");
dataSource.setFields(titleField, linkField);
ListGrid grid = new ListGrid();
grid.setAutoFetchData(true);
grid.setHeight(200);
grid.setWidth100();
grid.setDataSource(dataSource);
grid.draw();
}
}
This works well for GETs but how about PUTs, POSTs and DELETEs?
Can anyone share some code or point me to a resource which demonstrates how to do other RESTful operations from a SmartGWT client?
Thanks