PDA

View Full Version : ext-gwt???(2.0.3)?Page????????



sigmat
4 Oct 2009, 11:35 PM
?????????

DB???????Grid????????????????
???loader.load() ???????????????
????DB????????????????????loader.load()??????
?????????????????????????????

????????
...
// 192.168.0.1/getDBInfo.do???????????Json?????DB??????

RequestBuilder builder = new RequestBuilder( RequestBuilder.GET, "http://192.168.0.1/getDBInfo.do?random=" + Math.random() );

builder.setHeader("Cache-Control", "no-cache");

HttpProxy<String> proxy = new HttpProxy<String>(builder);

JsonLoadResultReader<ListLoadResult<ModelData>> reader = new JsonLoadResultReader<ListLoadResult<ModelData>>( type );

final BaseListLoader<ListLoadResult<ModelData>> loader = new BaseListLoader<ListLoadResult<ModelData>>( proxy, reader);

ListStore<ModelData> store = new ListStore<ModelData>(loader);

final Grid<ModelData> grid = new Grid<ModelData>(store, cm); ...
...
// ???????????
loader.load();
...
...
// ??????????????????????
Button load = new Button("??", new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
loader.load();
}
});

????????????????????????????????????????
???URL???????????????????URL???&Math.random()?????????
?Htm???l?
<meta http-equiv="Pragma" content="no-cache"> <meta http-equiv="Cache-Control" content="no-cache">
java????
builder.setHeader("Cache-Control", "no-cache");

????????2.0.3 ext-gwt BaseLoader?proxy???????????
loader.load()???????proxy??????????????

?????????????????????????????????
?????????????????????????
ext-gwt?????????????????????????

????????Gxt2.0.1??????????????????????

katsu_taira
13 Oct 2009, 4:36 PM
?????????????
????ext gwt 2.0.1??????????????????????????????????????????????????????????????????Json?????????????????????????????????????????????
????????2.0.3?????????????????
??????????ext gwt?JsonLoadResultReader??????????????????????

????????????????????????Json????????????????

---???---
/**
* This is the entry point method.
*/
public void onModuleLoad() {
Button bt = new Button("??");
RootPanel.get("sendButtonContainer").add(bt);

String url = GWT.getHostPageBaseURL() + "data.json";

RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);

HttpProxy<String> proxy = new HttpProxy<String>(builder);
ModelType type = new ModelType();
type.setRoot("address");
type.addField("prefecture", "prefecture");
type.addField("city", "city");
type.addField("town", "town");

List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
columns.add(new ColumnConfig("prefecture", "prefecture", 200));
columns.add(new ColumnConfig("city", "city", 200));
columns.add(new ColumnConfig("town", "town", 200));
ColumnModel cm = new ColumnModel(columns);

JsonLoadResultReader<ListLoadResult<ModelData>> reader = new JsonLoadResultReader<ListLoadResult<ModelData>>(
type);

final BaseListLoader<ListLoadResult<ModelData>> loader = new BaseListLoader<ListLoadResult<ModelData>>(
proxy, reader);

ListStore<ModelData> store = new ListStore<ModelData>(loader);

final Grid<ModelData> grid = new Grid<ModelData>(store, cm);
RootPanel.get("sendButtonContainer").add(grid);
grid.setBorders(true);
grid.setHeight(300);

loader.load();

bt.addSelectionListener(new SelectionListener<ButtonEvent>() {

@Override
public void componentSelected(ButtonEvent ce) {
loader.load();
}
});

}

---Json????---
{"address":[{"city":"cde","prefecture":"abc","town":"efg"},{"city":"345","prefecture":"123","town":"567"}]}

?????????????

sigmat
18 Oct 2009, 6:31 PM
?????????????:)

?????????2.0.3?SVN??????????????????????????

??????????????

katsu_taira (http://www.extjs.com/forum/member.php?u=64436)????????????????????????????????????????????????????????

???????????IE?6.0???

???????????

katsu_taira
20 Oct 2009, 1:42 AM
IE??????????????????????????????????????????????????????????
URL?????????&Math.random()??????????????????????????URL???????????????

load???LoadConfig?????????????????URL?request parm????????
LoadConfig????????????????URL????????????
??????????????????????????????????????????

??????????LoadConfig??????????????????????
loader.setReuseLoadConfig(true);
???????????????

?????????????

---???---
/**
* This is the entry point method.
*/
public void onModuleLoad() {
Button bt = new Button("??");
RootPanel.get("sendButtonContainer").add(bt);

String url = GWT.getHostPageBaseURL() + "data.json";

RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);

HttpProxy<String> proxy = new HttpProxy<String>(builder);
ModelType type = new ModelType();
type.setRoot("address");
type.addField("prefecture", "prefecture");
type.addField("city", "city");
type.addField("town", "town");

List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
columns.add(new ColumnConfig("prefecture", "prefecture", 200));
columns.add(new ColumnConfig("city", "city", 200));
columns.add(new ColumnConfig("town", "town", 200));
ColumnModel cm = new ColumnModel(columns);

JsonLoadResultReader<ListLoadResult<ModelData>> reader = new JsonLoadResultReader<ListLoadResult<ModelData>>(
type);

final BaseListLoader<ListLoadResult<ModelData>> loader = new BaseListLoader<ListLoadResult<ModelData>>(
proxy, reader);

ListStore<ModelData> store = new ListStore<ModelData>(loader);

final Grid<ModelData> grid = new Grid<ModelData>(store, cm);
RootPanel.get("sendButtonContainer").add(grid);
grid.setBorders(true);
grid.setHeight(300);

//???!! loadConfig?request parm random???
final ListLoadConfig config = new BaseListLoadConfig();
config.set("random", Math.random());
//???!! ??loadConfig??????
loader.setReuseLoadConfig(true);
//???!! loadConfig?load??????
loader.load(config);

bt.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
//???!! loadConfig?request parm random????
config.set("random", Math.random());
loader.load();
}
});

}