スタブ化した REST サービス用の単純なクライアントを作成しているときに、smartGWT の RestDataSource クラスが理解できる xml のタイプに制限されていることに気付きました。すべての REST リソースは、次の形式の XML で応答する必要があります。
<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>
..唯一のバリアントは someField/someOtherField タグです。
この構造は、名前と値のペアにすぎませんが、うまくいきません。
その後、SmartGWT ショーケースでこのデモを見ました...
http://www.smartclient.com/smartgwtee/showcase/#data_integration_server_rss
これは、次のように表示するために任意の形式でxmlを使用する方法を示しています...
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();
}
}
これは GET ではうまく機能しますが、PUT、POST、DELETE ではどうでしょうか?
誰でもコードを共有したり、SmartGWT クライアントから他の RESTful 操作を実行する方法を示すリソースを教えてもらえますか?
ありがとう