我正在嘗試將數據從服務器轉換爲客戶端(GXT Grid)。 在服務器端,我有一個數據列表和它的好。 然後我實現RPC方法並假設它也可以。這裏是代碼:GWT RPC和數據轉換爲GXT Grid
GWTService
@RemoteServiceRelativePath("gwtservice") public interface GWTService extends RemoteService { public List<WebasystProductData> getWebasystProductData(); }
GWTServiceAsynch
public interface GWTServiceAsync { public void getWebasystProductData(AsyncCallback<List<WebasystProductData>> callback); }
GWTServiceImpl
public class GWTServiceImpl extends RemoteServiceServlet implements GWTService { //private Map<String, WebasystProductData> productData; public List<WebasystProductData> getWebasystProductData() { WebasystConnection waConn = new WebasystConnection(); List<WebasystProductData> waPD = waConn.getWebasystProductData(); return waPD; }
然後我使用我的beanmodel,beanmodelreader,listloader,listore和grid實現代理。
...
rpc = RpcInit.initRpc();
RpcProxy<BeanModel> proxy = new RpcProxy<BeanModel>() {
@Override
public void load(Object loadConfig, AsyncCallback callback) {
rpc.getWebasystProductData(callback);
}
};
BeanModelReader reader = new BeanModelReader();
BaseListLoader loader = new BaseListLoader(proxy, reader);
ListStore<BeanModel> store = new ListStore<BeanModel>(loader);
List<ColumnConfig> col = new ArrayList<ColumnConfig>();
ColumnConfig column = new ColumnConfig();
column.setId("productIdWA");
column.setHeader("ProductID");
column.setWidth(50);
col.add(column);
column = new ColumnConfig();
column.setId("productNameWA");
column.setHeader("productName");
column.setWidth(120);
col.add(column);
column = new ColumnConfig();
column.setId("productPriceWA");
column.setHeader("productPrice");
column.setWidth(80);
col.add(column);
column = new ColumnConfig();
column.setId("categoryIdWA");
column.setHeader("categoryID");
column.setWidth(80);
column.setAlignment(HorizontalAlignment.RIGHT);
col.add(column);
時候開始我的應用程序 - 內網的數據。不知道最新的問題,沒有錯誤... 假設問題出在客戶端代碼
你是蘇WebasystProductData是一個Serializable類?什麼是waConn.getWebasystProductData()返回的List的實現; ? – jonasr