Using REST Services with SmartGWT

When creating a simple client for the REST service that I missed, I noticed that the smartGWT RestDataSource class is limited to the xml type that 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 option is someField / someOtherField tags.

This structure, which is slightly larger than name / value pairs, will not work for us.

Then I saw this demo on a SmartGWT storefront ...

http://www.smartclient.com/smartgwtee/showcase/#data_integration_server_rss

Which shows how to consume xml in arbitrary format for display 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 GET, but what about PUT, POST, and DELETE?

Can someone share some code or point me to a resource that demonstrates how to perform other RESTful operations from the SmartGWT client?

thanks

+4
source share

All Articles