Hi, i'm newbie in smartgwt..
i have some problem to consume json from web service. First of all i have two projects. Web Service using Restlet and SmartGWT LGPL version, my problem is I want to consume json from restlet for my client side(smartgwt).
Here is my code :
Anybody help?
Thanks
i have some problem to consume json from web service. First of all i have two projects. Web Service using Restlet and SmartGWT LGPL version, my problem is I want to consume json from restlet for my client side(smartgwt).
Here is my code :
Code:
package com.berca.ahu.fidusia.client.ui.data; import org.restlet.gwt.Client; import org.restlet.gwt.data.Protocol; import com.smartgwt.client.data.OperationBinding; import com.smartgwt.client.data.XJSONDataSource; import com.smartgwt.client.data.fields.DataSourceIntegerField; import com.smartgwt.client.data.fields.DataSourceTextField; import com.smartgwt.client.types.DSDataFormat; import com.smartgwt.client.types.DSOperationType; import com.smartgwt.client.types.DSProtocol; import com.smartgwt.client.types.RPCTransport; public class DSUser extends XJSONDataSource{ private static DSUser instance = null; final Client client = new Client(Protocol.HTTP); final String URL ="http://localhost:8080/AHUFidusiaWebservice/users/1"; public static DSUser getInstance() { if (instance == null) { instance = new DSUser("DSUser_JSON"); } return instance; } public DSUser(String title) { setDataProtocol(DSProtocol.POSTPARAMS); setDataFormat(DSDataFormat.JSON); DataSourceTextField name = new DataSourceTextField("username", "Username"); name.setValueXPath("username"); DataSourceIntegerField id = new DataSourceIntegerField("id", "Id"); id.setValueXPath("id"); id.setPrimaryKey(true); setDataURL(URL); OperationBinding fetch = new OperationBinding(); fetch.setOperationType(DSOperationType.FETCH); fetch.setDataProtocol(DSProtocol.POSTMESSAGE); setRecordXPath("/users"); setDataTransport(RPCTransport.SCRIPTINCLUDE); setCallbackParam("callback"); setFields(id, name); } }
Thanks
Comment