PDA

View Full Version : Data loading into live grid via RPCProxy does not work



OZKA
23 Dec 2010, 6:31 AM
Loader.BeforeLoad event does not fire


class LiveGridExample extends LayoutContainer {
private BasePagingLoader<PagingLoadResult<BeanModelTag>> loader;
private BeanModelReader reader;
private RpcProxy<PagingLoadResult<BeanModelTag>> proxy;
@Override
protected void onRender(Element parent, int index) {
super.onRender(parent, index);

FlowLayout layout = new FlowLayout(10);
setLayout(layout);

final TableMainServiceAsync service = (TableMainServiceAsync) GWT.create(TableMainService.class);



proxy = new RpcProxy<PagingLoadResult<BeanModelTag>>() {

@Override
protected void load(Object loadConfig,
AsyncCallback<PagingLoadResult<BeanModelTag>> callback) {
service.runService((PagingLoadConfig) loadConfig, new TableRequestContext(TableRequestAction.SHOW_ADV), callback);
}

};

reader = new BeanModelReader();
loader = new BasePagingLoader<PagingLoadResult<BeanModelTag>>(proxy, reader);

loader.addListener(Loader.BeforeLoad, new Listener<LoadEvent>() {
public void handleEvent(LoadEvent be) {
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
GWT.log("Log this");
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
BasePagingLoadConfig m = be.<BasePagingLoadConfig> getConfig();
m.set("start", m.get("offset"));
m.set("ext", "js");
m.set("lightWeight", true);
m.set("sort", (m.get("sortField") == null) ? "" : m.get("sortField"));
m.set("dir", (m.get("sortDir") == null || (m.get("sortDir") != null && m.<SortDir> get("sortDir").equals(
SortDir.NONE))) ? "" : m.get("sortDir"));

}
});
loader.setSortDir(SortDir.DESC);
loader.setSortField("lastpost");

loader.setRemoteSort(true);

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

List<ColumnConfig> columns = new ArrayList<ColumnConfig>();

ColumnConfig id = new ColumnConfig("id", "id", 50);


columns.add(id);
columns.add(new ColumnConfig("name", "Name", 200));



ColumnModel cm = new ColumnModel(columns);

final Grid<BeanModel> grid = new Grid<BeanModel>(store, cm);
grid.setBorders(true);
grid.setAutoExpandColumn("name");
grid.setLoadMask(true);
grid.setStripeRows(true);

LiveGridView liveView = new LiveGridView();

liveView.setEmptyText("No rows available on the server.");
//liveView.setRowHeight(32);
grid.setView(liveView);

ContentPanel panel = new ContentPanel();
panel.setFrame(true);
panel.setCollapsible(true);
panel.setAnimCollapse(false);
panel.setHeading("LiveGrid Grid");
panel.setLayout(new FitLayout());
panel.add(grid);
panel.setSize(600, 350);
grid.getAriaSupport().setLabelledBy(panel.getHeader().getId() + "-label");

ToolBar toolBar = new ToolBar();
toolBar.add(new FillToolItem());

LiveToolItem item = new LiveToolItem();
item.bindGrid(grid);

toolBar.add(item);
panel.setBottomComponent(toolBar);

add(panel);

}

}


or check it on the gist github line 32 (https://gist.github.com/74ea6f6c4d4e1c03702a)

sven
23 Dec 2010, 7:00 AM
I dont see any big problem in this code. Have you tried to wrap it into a small, standalone testcase? Also if serverside would fail, beforeload event should fire

OZKA
23 Dec 2010, 7:13 AM
It is sencha's code sample of live grid, i just replaced JsonProxy to RPCProxy, after replacing the line contained "GWT.log("Log this"); " does not execute itself, for example on scrolling event

sven
23 Dec 2010, 7:15 AM
I dont know without having some complete testcase, also instead of using BeanModelTag as genric, you should use BeanModel

OZKA
23 Dec 2010, 8:20 AM
How can i create BeanModel on the server side code?

sven
23 Dec 2010, 8:24 AM
You dont. Thats why you use BeanModelReader. Simple return your real bean, that either implements BeanModelTag or has a BeanModelMarker defined to match it.

OZKA
24 Dec 2010, 2:36 AM
You dont. Thats why you use BeanModelReader. Simple return your real bean, that either implements BeanModelTag or has a BeanModelMarker defined to match it.
Thank you! Your advice was useful to solve my issue.