_sandro_
19 Sep 2008, 9:05 AM
I have modified the file BeanModelGridExample.java in the source code examples, adding the gird to a Window with a button to display it and load the data:
public class NewGrid extends LayoutContainer implements EntryPoint {
protected void onRender(Element parent, int index) {
super.onRender(parent, index);
final Window w = new Window();
w.setLayout(new FitLayout());
w.setCollapsible(true);
w.setSize(600, 400);
final ExampleServiceAsync service = (ExampleServiceAsync)
Registry.get("service");
RpcProxy proxy = new RpcProxy() {
@Override
public void load(Object loadConfig, AsyncCallback callback) {
service.getCustomers(callback);
}
};
BeanModelReader reader = new BeanModelReader();
final ListLoader loader = new BaseListLoader(proxy, reader);
ListStore store = new ListStore<BeanModel>(loader);
w.add(getTable(store));
Button btn = new Button("Show", new SelectionListener<ComponentEvent>() {
@Override
public void componentSelected(ComponentEvent ce) {
w.show();
loader.load();
}
});
add(btn);
}
private Grid getTable(ListStore store) {
List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
columns.add(new ColumnConfig("name", "Name", 100));
columns.add(new ColumnConfig("email", "Email", 100));
columns.add(new ColumnConfig("age", "Age", 100));
columns.add(new ColumnConfig("name", "Name", 100));
columns.add(new ColumnConfig("email", "Email", 100));
columns.add(new ColumnConfig("age", "Age", 100));
ColumnModel cm = new ColumnModel(columns);
Grid<BeanModel> grid = new Grid(store, cm);
grid.setBorders(true);
grid.setLoadMask(true);
grid.getView().setForceFit(true);
return grid;
}
public void onModuleLoad() {
ExampleServiceAsync service=(ExampleServiceAsync)GWT.create(ExampleService.class);
ServiceDefTarget endpoint = (ServiceDefTarget) service;
String moduleRelativeURL = GWT.getModuleBaseURL() + "service";
endpoint.setServiceEntryPoint(moduleRelativeURL);
Registry.register("service", service);
RootPanel.get().add(this);
}
}and replaced the getCustomers() method in the ExampleServiceImpl.java with this lines of code:
public List<Customer> getCustomers() {
List<Customer> customers = new ArrayList();
for (int i=0; i<400; i++) {
Customer customer = new Customer("customer name","e-mail", i);
customers.add(customer);
}
return customers;
}Doing so, the grid seems to be four times slower to display all the 400 rows in web mode (near to 30 seconds on P4 with firefox 2) than in host mode (7-8 sec).
This is the configuration used for this test:
GWT 1.5.2
GXT 1.1
Firefox 2.0.0.12 (firebug turned off)
Linux openSUSE 10.3
public class NewGrid extends LayoutContainer implements EntryPoint {
protected void onRender(Element parent, int index) {
super.onRender(parent, index);
final Window w = new Window();
w.setLayout(new FitLayout());
w.setCollapsible(true);
w.setSize(600, 400);
final ExampleServiceAsync service = (ExampleServiceAsync)
Registry.get("service");
RpcProxy proxy = new RpcProxy() {
@Override
public void load(Object loadConfig, AsyncCallback callback) {
service.getCustomers(callback);
}
};
BeanModelReader reader = new BeanModelReader();
final ListLoader loader = new BaseListLoader(proxy, reader);
ListStore store = new ListStore<BeanModel>(loader);
w.add(getTable(store));
Button btn = new Button("Show", new SelectionListener<ComponentEvent>() {
@Override
public void componentSelected(ComponentEvent ce) {
w.show();
loader.load();
}
});
add(btn);
}
private Grid getTable(ListStore store) {
List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
columns.add(new ColumnConfig("name", "Name", 100));
columns.add(new ColumnConfig("email", "Email", 100));
columns.add(new ColumnConfig("age", "Age", 100));
columns.add(new ColumnConfig("name", "Name", 100));
columns.add(new ColumnConfig("email", "Email", 100));
columns.add(new ColumnConfig("age", "Age", 100));
ColumnModel cm = new ColumnModel(columns);
Grid<BeanModel> grid = new Grid(store, cm);
grid.setBorders(true);
grid.setLoadMask(true);
grid.getView().setForceFit(true);
return grid;
}
public void onModuleLoad() {
ExampleServiceAsync service=(ExampleServiceAsync)GWT.create(ExampleService.class);
ServiceDefTarget endpoint = (ServiceDefTarget) service;
String moduleRelativeURL = GWT.getModuleBaseURL() + "service";
endpoint.setServiceEntryPoint(moduleRelativeURL);
Registry.register("service", service);
RootPanel.get().add(this);
}
}and replaced the getCustomers() method in the ExampleServiceImpl.java with this lines of code:
public List<Customer> getCustomers() {
List<Customer> customers = new ArrayList();
for (int i=0; i<400; i++) {
Customer customer = new Customer("customer name","e-mail", i);
customers.add(customer);
}
return customers;
}Doing so, the grid seems to be four times slower to display all the 400 rows in web mode (near to 30 seconds on P4 with firefox 2) than in host mode (7-8 sec).
This is the configuration used for this test:
GWT 1.5.2
GXT 1.1
Firefox 2.0.0.12 (firebug turned off)
Linux openSUSE 10.3