PDA

View Full Version : GXT 2.1.1 with Gilead 1.3.0



maratkalibek
18 Feb 2010, 10:01 PM
GWT 2.0.2
GXT 2.1.1
Gilead4GWT 1.3.0
------------------------------------------

I'm trying to use Gilead with GXT for displaying bean models in Grid. Bean models are taken from Hibernate, but they are not shown in grid. Code for displaying grid is



RpcProxy<PagingLoadResult<Document>> proxy = new RpcProxy<PagingLoadResult<Document>>() {
@Override
protected void load(Object loadConfig, AsyncCallback<PagingLoadResult<Document>> callback) {
PagingLoadConfig config = (PagingLoadConfig) loadConfig;
mainService.getDocuments(
config.getOffset(),
config.getLimit(),
callback
);
}
};
BeanModelReader reader = new BeanModelReader();

PagingLoader<PagingLoadResult<BeanModel>> loader = new BasePagingLoader<PagingLoadResult<BeanModel>>(proxy,reader);

PagingToolBar toolbar = new PagingToolBar(50);
toolbar.bind(loader);

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

List<ColumnConfig> columns = new LinkedList<ColumnConfig>();
columns.add(new RowNumberer());
ColumnConfig config = new ColumnConfig();
config.setId("publicNumber");
config.setHeader(strings.name());
config.setMenuDisabled(true);
config.setRenderer(new GridCellRenderer<ModelData>() {
@Override
public Object render(ModelData model, String property,
ColumnData config, int rowIndex, int colIndex,
ListStore<ModelData> store, Grid<ModelData> grid) {
Integer publicNumber = model.get("publicNumber");
String title = strings.noDataInThisLanguage();
String description = "";

DocumentTitle _title = null;

Set<DocumentTitle> titles = model.get("titles");
for (DocumentTitle t : titles) {
if (t.getLanguage().getCode().trim().equals(language)) {
_title = t;
break;
}
}

if (title!=null) {
title = _title.getTitle();
description = _title.getDescription();
}
StringBuffer sb = new StringBuffer();
sb.append("<b>");sb.append(title);sb.append("</b>");
if (!description.trim().equals("")) {
sb.append("<div>");sb.append(description);sb.append("</div>");
}
sb.append("<div>");
return sb.toString();
}
});
columns.add(config);

ColumnModel cm = new ColumnModel(columns);

Grid<BeanModel> grid = new Grid<BeanModel>(store,cm);
grid.setAutoExpandColumn("publicNumber");
grid.getView().setEmptyText(strings.pressSearchToView());
grid.setHeight(200);
grid.setAutoHeight(true);
grid.getView().setForceFit(true);
grid.setLoadMask(true);

chalu
2 Mar 2010, 4:39 AM
Does your grid data show up without that cell renderer :-/
I am also new to Hibernate / JPA and Gilead, and I equally have this problem atimes but usually when my entity is loading some other entity eagerly or it has a List<SomeOtherEntity> feild has a @OneToMany maping. I think this is where Gilead has to come it, but like I said I am yet to fully understand and use it well.

si_gee2000
8 Jun 2010, 6:28 AM
I would really encourage you to persevere - using Gilead with GXT has been a fantastic combination for me. I wrote my first major gwt app using gxt pre release 1, and there was no Gilead then, so I had to do a lot of work to serialise out "objects" myself, but more importantly I had to do even more work to create and update complex objects going back in to the server side. Once you have Gilead setup and working as part of your serialization then the most common problem will be that Gilead does not fetch non-eager collections in your object attributes. Obviously the simplest answer is to annotate them as EAGER fetch attributes. I suggest hitting the code in the Development mode with a debugger and see what you are getting back from the server.. I suspect it is either a LAZY fetch attribute not being populated or it is sending the right data back and you simply have a rendering issue.

chalu
1 Aug 2010, 4:04 PM
@si_gee2000 I'll rather be carefull with eager collections else one can end up pulling the entire database in a single select operation, my experience has been to use (at least start with) LAZY fetches, many times "too much" EAGER causes my stuff not to render after been fetched.