0
我試圖讓一個簡單的GXT應用程序使用REST從外部服務器檢索數據。Ext-GWT(GXT)簡單REST嘗試不起作用
我發現以下example online,對於我的生活,我無法理解爲什麼我的桌子沒有得到填充。它也看起來好像數據沒有被檢索。我將不勝感激任何幫助!謝謝。
/*
* Ext GWT 2.2.3 - Ext for GWT
* Copyright(c) 2007-2010, Ext JS, LLC.
* [email protected]
*
* http://extjs.com/license
*/
package com.extjs.gxt.samples.mail.client.widget;
import java.util.ArrayList;
import java.util.List;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.Style.Orientation;
import com.extjs.gxt.ui.client.data.BaseListLoader;
import com.extjs.gxt.ui.client.data.HttpProxy;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.data.ModelType;
import com.extjs.gxt.ui.client.data.XmlReader;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.grid.Grid;
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
import com.google.gwt.http.client.RequestBuilder;
public class ContactPanel extends ContentPanel {
@SuppressWarnings("rawtypes")
public ContactPanel() {
setHeading("Contacts");
setStyleAttribute("margin", "5px");
setHeaderVisible(true);
setBodyBorder(true);
setAutoHeight(true);
setLayout(new RowLayout(Orientation.VERTICAL));
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
configs.add(new ColumnConfig("departureCity", "From", 120));
configs.add(new ColumnConfig("arrivalCity", "To", 120));
ColumnConfig config = new ColumnConfig("departureTime", "departureTime", 150);
config.setAlignment(HorizontalAlignment.LEFT);
configs.add(config);
configs.add(new ColumnConfig("arrivalTime", "Arrivaltime", 150));
configs.add(new ColumnConfig("flightNo", "Flightnr", 70));
config = new ColumnConfig("price", "Price", 120);
config.setAlignment(HorizontalAlignment.LEFT);
configs.add(config);
ColumnModel cm = new ColumnModel(configs);
ModelType type = new ModelType();
type.setRoot("flightList");
type.setRecordName("flight");
type.addField("departureCity");
type.addField("arrivalCity");
type.addField("departureTime");
type.addField("arrivalTime");
type.addField("flightNo");
type.addField("price");
// use a http proxy to get the data
RequestBuilder builder = new RequestBuilder(
RequestBuilder.GET,
//"/flights.xml");
"http://tutorialsjava.com/demo/flights.xml");
HttpProxy proxy = new HttpProxy(builder);
// need a loader, proxy, and reader
XmlReader reader = new XmlReader(type);
final BaseListLoader loader = new BaseListLoader(proxy, reader);
ListStore<ModelData> store = new ListStore<ModelData>(loader);
final Grid grid = new Grid<ModelData>(store, cm);
grid.setStyleAttribute("borderTop", "none");
grid.setBorders(true);
grid.setStripeRows(true);
grid.setAutoWidth(true);
grid.setHeight(160);
grid.getView().setForceFit(true);
loader.setRemoteSort(true);
loader.load();
add(grid);
}
}
您是否嘗試過在HttpProxy.java中調試加載方法? – DonX 2011-04-19 10:34:57