2013-02-14 19 views
0

在我的应用程序中我使用gwt 2.5.0和gxt 2.2.5。所以,我有我的ColumnConfig柱与此渲染:GXT model.get()返回错误类型的实例

column.setRenderer(new GridCellRenderer() { 

      @Override 
      public Text render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore listStore, Grid grid) { 
       List<AccountGroupDto> accountGroups = model.get(property); 
       // some stuff here 

       return groupsText; 
      } 
     }); 

但是,当我尝试做一些与我的名单emenetns,我得到了某种类型转换错误。我使用了一个调试器,看起来我的列表元素的类型是com.example.core.application.api.BeanModel_com_example_core_application_api_AccountGroupDto,它不能转换为com.example.core.application.api.AccountGroupDto,它应该是。

此错误出现时,我已经从1.7和GXT从2.0.1

回答

0

升级GWT类型添加到您的GridCellRenderer(acording到你的错误我asume您使用BeanModel来完完全全),因此使用此类型:

column.setRenderer(new GridCellRenderer<BeanModel>() { 

      @Override 
      public Object render(BeanModel model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<BeanModel> store, Grid<BeanModel> grid) { 
       // ... 

由渲染事件返回的模型它的一个BeanModel,现在获取原始元素使用模型的.getBean属性。

OriginalObjectType myObj = model.getBean(); 

现在你可以从MyObj中得到你的对象:

List<AccountGroupDto> accountGroups = myObj.get(property); 

希望这有助于。