raj_begood
19 Feb 2009, 5:58 AM
Hi,
I am trying to build a dynamic grid where the columns and rows vary depending on what the server sends back, it seems fairly easy when looking at the examples such as PagingBeanModelGridExample, the main difference is that I want to pull back a model object that can have any number of properties.
Therefore I am not creating any set/get methods, but using set(x,x) to set the values I am sending from the backend. I am seeing nothing showing up in the Grid, although all the columns i expect to see are present, i am seeing a load exception:
[STDOUT] LOGGER.loaderLoadException= - No BeanModelFactory found for class com.x.y.z.DatabaseRow
The results are actually being sent to the client as I am debugging, but the store has nothing in it.
Any ideas whats going on here ? I checked the forums and came but nothing has turned up, I even called the load
method after the store was created.
DatabaseRow
public class DatabaseRow extends BeanModel implements IsSerializable {
public DatabaseRow() {
}
}
RpcProxy proxy = new RpcProxy() {
@Override
public void load(Object loadConfig, AsyncCallback callback) {
getServices().loadDatabase((PagingLoadConfig) loadConfig, callback);
}
};
// loader
BasePagingLoader loader = new BasePagingLoader(proxy, new BeanModelReader());
loader.setRemoteSort(true);
loader.addLoadListener(new LoadListener() {
public void loaderBeforeLoad(LoadEvent le) {
}
public void loaderLoad(LoadEvent le) {
}
public void loaderLoadException(LoadEvent le) {
UILogger.log("LOGGER.loaderLoadException=", le.exception.getMessage());
}
});
ListStore<BeanModel> store = new ListStore<BeanModel>(loader);
loader.load(0, 5); // moved here after checking on forums
final PagingToolBar toolBar = new PagingToolBar(5);
toolBar.bind(loader);
List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
for (String name : database.getMeta()) {
columns.add(new ColumnConfig(name, name, 100));
}
ColumnModel cm = new ColumnModel(columns);
Grid<BeanModel> grid = new Grid<BeanModel>(store, cm);
grid.setLoadMask(true);
grid.setBorders(true);
..
ServerSide is setting the values:
public PagingLoadResult<DatabaseRow> loadDatabase(PagingLoadConfig config) {
List<DatabaseRow> databaseRows = internalloadDatabase();
ArrayList<DatabaseRow> sublists = new ArrayList<DatabaseRow>();
int start = config.getOffset();
int limit = databaseRows.size();
if (config.getLimit() > 0) {
limit = Math.min(start + config.getLimit(), limit);
}
for (int i = config.getOffset(); i < limit; i++) {
sublists.add(databaseRows.get(i));
}
BasePagingLoadResult result = new BasePagingLoadResult<DatabaseRow>(sublists, config.getOffset(), databaseRows.size());
return result;
}
// This is a a dummy method to show how the DatabaseRow is being constructed, in reality
// this can contain any number of params
private List<DatabaseRow> internalloadDatabase() {
List<DatabaseRow> grid = new ArrayList<DatabaseRow>();
DatabaseRow row = new DatabaseRow();
row.set("Movie Name","Matrix");
row.set("Stars","Neo,Sven");
grid.add(row);
return grid;
}
I am trying to build a dynamic grid where the columns and rows vary depending on what the server sends back, it seems fairly easy when looking at the examples such as PagingBeanModelGridExample, the main difference is that I want to pull back a model object that can have any number of properties.
Therefore I am not creating any set/get methods, but using set(x,x) to set the values I am sending from the backend. I am seeing nothing showing up in the Grid, although all the columns i expect to see are present, i am seeing a load exception:
[STDOUT] LOGGER.loaderLoadException= - No BeanModelFactory found for class com.x.y.z.DatabaseRow
The results are actually being sent to the client as I am debugging, but the store has nothing in it.
Any ideas whats going on here ? I checked the forums and came but nothing has turned up, I even called the load
method after the store was created.
DatabaseRow
public class DatabaseRow extends BeanModel implements IsSerializable {
public DatabaseRow() {
}
}
RpcProxy proxy = new RpcProxy() {
@Override
public void load(Object loadConfig, AsyncCallback callback) {
getServices().loadDatabase((PagingLoadConfig) loadConfig, callback);
}
};
// loader
BasePagingLoader loader = new BasePagingLoader(proxy, new BeanModelReader());
loader.setRemoteSort(true);
loader.addLoadListener(new LoadListener() {
public void loaderBeforeLoad(LoadEvent le) {
}
public void loaderLoad(LoadEvent le) {
}
public void loaderLoadException(LoadEvent le) {
UILogger.log("LOGGER.loaderLoadException=", le.exception.getMessage());
}
});
ListStore<BeanModel> store = new ListStore<BeanModel>(loader);
loader.load(0, 5); // moved here after checking on forums
final PagingToolBar toolBar = new PagingToolBar(5);
toolBar.bind(loader);
List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
for (String name : database.getMeta()) {
columns.add(new ColumnConfig(name, name, 100));
}
ColumnModel cm = new ColumnModel(columns);
Grid<BeanModel> grid = new Grid<BeanModel>(store, cm);
grid.setLoadMask(true);
grid.setBorders(true);
..
ServerSide is setting the values:
public PagingLoadResult<DatabaseRow> loadDatabase(PagingLoadConfig config) {
List<DatabaseRow> databaseRows = internalloadDatabase();
ArrayList<DatabaseRow> sublists = new ArrayList<DatabaseRow>();
int start = config.getOffset();
int limit = databaseRows.size();
if (config.getLimit() > 0) {
limit = Math.min(start + config.getLimit(), limit);
}
for (int i = config.getOffset(); i < limit; i++) {
sublists.add(databaseRows.get(i));
}
BasePagingLoadResult result = new BasePagingLoadResult<DatabaseRow>(sublists, config.getOffset(), databaseRows.size());
return result;
}
// This is a a dummy method to show how the DatabaseRow is being constructed, in reality
// this can contain any number of params
private List<DatabaseRow> internalloadDatabase() {
List<DatabaseRow> grid = new ArrayList<DatabaseRow>();
DatabaseRow row = new DatabaseRow();
row.set("Movie Name","Matrix");
row.set("Stars","Neo,Sven");
grid.add(row);
return grid;
}