PDA

View Full Version : BasePagingLoader: No BeanModelFactory found for class XXX



raj_begood
19 Feb 2009, 6:02 AM
BasePagingLoader: No BeanModelFactory found for class XXX

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

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);


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;
}

sdc
19 Feb 2009, 7:46 AM
Check that your DatabaseRow implements BeanModelTag or that there is an interface extending BeanModelMarker with the annotation @BEAN(DatabaseRow)

raj_begood
19 Feb 2009, 8:11 AM
Hi sdc

I made the changes, but this only prevents the load exception, the store still contains nothing when queried by calling:

store.getCount()



public class DatabaseRow extends BeanModel implements BeanModelTag, IsSerializable {
public DatabaseRow() {
}
}


I'll keep digging ..

sdc
19 Feb 2009, 8:17 AM
I don't know if this is the problem but you should not extend BeanModel.
You should either implements BeanModelTag or create an interface :

@BEAN(DatabaseRow.class)
interface DatabaseRowMarker{}

raj_begood
19 Feb 2009, 8:41 AM
Hmm I also tried extends BaseModelData, but to no avail :-(

What I am trying to acheive is the grid to display a model object that can contain a varying list of properties/values thats why I was extending BeanModel to take advantage of the generic set/get way of adding values.

I'm not sure if under the covers ext is using relfection to inspect the model objects methods and its using reflection to get the values.

I'll keep investigating. .

Km.kanagaraj
14 Jun 2010, 9:54 PM
I am facing the same issue.

I want to display a list of alerts in a Pagin grid,

The columns and rows of the grid will vary dynamically

The following is my bean


public class AlertBean extends BaseModelDate{

// using set(property, value) for setting the required details
}

@BEAN(AlertBean.class)
public interface AlertBeanModel extends BeanModelMarker{
}


but while retrieving records from the Server using RpcProxy & BasePagingLoader it doesnt contain any values, the grid rows simply blank rows

I am struggling in this for 2 days, can any one please help me in this.