PDA

View Full Version : java.lang.ClassCastException GWT1.7



aurelie
6 Aug 2009, 5:54 AM
I want to obtain a WidgetRendererGrid.
here is my class to obtain the grid :


public class TableauDomaines extends LayoutContainer {
private QualityConstants constants = GWT.create(QualityConstants.class);

@Override
protected void onRender(Element parent, int index) {
super.onRender(parent, index);

GridCellRenderer<DomaineIndicateurBean> supprimer = new GridCellRenderer<DomaineIndicateurBean>(){
public Object render(final DomaineIndicateurBean model, String property, ColumnData config, final int rowIndex,
final int colIndex, ListStore<DomaineIndicateurBean> store, Grid<DomaineIndicateurBean> grid) {
Button b = new Button((String) model.get(property), new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
Info.display(model.getNom(), "<ul><li>" + model.getCode() + "</li></ul>");
}
});
b.setWidth(grid.getColumnModel().getColumnWidth(colIndex) - 10);
b.setToolTip("Click for more Informations");

return b;
}
};

final DomaineServiceAsync domaineService = (DomaineServiceAsync)GWT.create(DomaineService.class);

// proxy and reader
RpcProxy<List<DomaineIndicateurBean>> proxy = new RpcProxy<List<DomaineIndicateurBean>>() {
@Override
public void load(Object loadConfig, AsyncCallback<List<DomaineIndicateurBean>> callback) {
domaineService.getListDomaines(callback);
}
};
BeanModelReader reader = new BeanModelReader();

// loader and store
ListLoader<ListLoadResult<DomaineIndicateurBean>> loader = new BaseListLoader<ListLoadResult<DomaineIndicateurBean>>(proxy, reader);
ListStore<DomaineIndicateurBean> store = new ListStore<DomaineIndicateurBean>(loader);
loader.load();


final List<ColumnConfig> configs = new ArrayList<ColumnConfig>();

//colonne des codes des domaines
ColumnConfig column = new ColumnConfig("code", constants.domain_code(), 300);
TextField<String> text = new TextField<String>();
text.setAllowBlank(false);
column.setEditor(new CellEditor(text));
configs.add(column);

//colonne pour la suppression des domaines
column = new ColumnConfig("supprimer", constants.button_delete(), 100);
column.setWidth(100);
column.setRenderer(supprimer);
configs.add(column);

ColumnModel cm = new ColumnModel(configs);

Grid<DomaineIndicateurBean> grid = new Grid<DomaineIndicateurBean>(store, cm);
grid.setAutoExpandColumn("code");
grid.setAutoHeight(true);
grid.setAutoWidth(true);
add(grid);
}
}

Here is my bean :


public class DomaineIndicateurBean extends BaseModel implements Serializable, ILightEntity, BeanModelTag {

private static final long serialVersionUID = 1L;
private String code;

public DomaineIndicateurBean() {
}

public DomaineIndicateurBean(String code){
set("code",code);
}

public String getCode() {
return get("code");
}

public void setCode(String code) {
set("code",code);
}


/*****************************************************/
/** FONCTIONS IMPLEMENTANT L'INTERFACE ILIGHTENTITY **/
/*****************************************************/

protected Map<String, String> _proxyInformations;

public Map<String, String> getProxyInformations()
{
return _proxyInformations;
}

@SuppressWarnings("unchecked")
public void setProxyInformations(Map informations)
{
_proxyInformations = informations;
}

public void addProxyInformation(String property,
String proxyInfo)
{
if (_proxyInformations == null)
{
_proxyInformations = new HashMap<String, String>();
}
_proxyInformations.put(property, proxyInfo);
}

public void removeProxyInformation(String property)
{
if (_proxyInformations != null)
{
_proxyInformations.remove(property);
}
}

public String getProxyInformation(String property)
{
if (_proxyInformations != null)
{
return _proxyInformations.get(property);
}
else
{
return null;
}
}

public String getDebugString()
{
if (_proxyInformations != null)
{
return _proxyInformations.toString();
}
else
{
return null;
}
}
}
I'm using gilead to integrate hibernate with GWT.
that's why my bean implements interfaces ILightEntity and BeanModelTag.
Before adding the gridCellRendreder, that worked.
now, it appears in the server log the following error :


Uncaught exception escaped
java.lang.ClassCastException: fr.bull.domain.BeanModel_fr_bull_domain_DomaineIndicateurBean cannot be cast to fr.bull.domain.DomaineIndicateurBean
at fr.bull.client.TableauDomaines$1.render(TableauDomaines.java:1)
at com.extjs.gxt.ui.client.widget.grid.GridView.getRenderedValue(GridView.java:1000)
at com.extjs.gxt.ui.client.widget.grid.GridView.doRender(GridView.java:849)
at com.extjs.gxt.ui.client.widget.grid.GridView.renderRows(GridView.java:1559)
at com.extjs.gxt.ui.client.widget.grid.GridView.afterRender(GridView.java:658)
at com.extjs.gxt.ui.client.widget.grid.Grid.afterRenderView(Grid.java:626)
at com.extjs.gxt.ui.client.widget.grid.Grid$1.run(Grid.java:616)
at com.google.gwt.user.client.Timer.fireImpl(Timer.java:160)
at com.google.gwt.user.client.Timer.fireAndCatch(Timer.java:146)
at com.google.gwt.user.client.Timer.fire(Timer.java:138)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:126)
at com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:155)
at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
at com.google.gwt.dev.SwtHostedModeBase.processEvents(SwtHostedModeBase.java:235)
at com.google.gwt.dev.HostedModeBase.pumpEventLoop(HostedModeBase.java:558)
at com.google.gwt.dev.HostedModeBase.run(HostedModeBase.java:405)
at com.google.gwt.dev.HostedMode.main(HostedMode.java:232)
Can someone help me please?

aurelie
20 Aug 2009, 12:16 AM
Has anybody already met this problem?