1 Reply Latest reply on Dec 16, 2008 7:41 AM by dmitri.ilyin

    Problem with ExtendedTableDataModel and rich:dataTable

      Hi,

      i'm trying to use ExtendedTabledataModel with rich:dataTable.
      I have implemented my DataProvider, here is the code:

      public class DiscreteTaskProvider implements DataProvider<DiscreteTask> {
       private static final long serialVersionUID = 1L;
      
       private static final Log log = LogFactory.getLog(DiscreteTaskProvider.class);
      
       private List<DiscreteTask> items;
      
       public DiscreteTaskProvider() {
       }
      
       public DiscreteTaskProvider(List<DiscreteTask> items) {
       this.items = items;
       }
      
       public void setItems(List<DiscreteTask> items) {
       this.items = items;
       }
      
       public DiscreteTask getItemByKey(Object key) {
       DiscreteTask result = null;
       if (key != null)
       for (DiscreteTask entity : getItems())
       if (key.equals(new DisplayableKey(entity))) {
       result = entity;
       break;
       }
       return result;
       }
      
       public List<DiscreteTask> getItems() {
       return items;
       }
      
       public List<DiscreteTask> getItemsByRange(int firstRow, int lastRow) {
       return getItems().subList(firstRow, lastRow);
       }
      
       public Object getKey(DiscreteTask item) {
       return new DisplayableKey(item);
       }
      
       public int getRowCount() {
       return getItems().size();
       }
      }
      

      I'm using my Own Class DisplayableKey as PK. So it is not a Integer. And it seems that this makes problem with rich:dataTable. The first load and show of table in browser just works but I get an exception if i try to sort the table.
      Caused by: javax.faces.convert.ConverterException: j_id33:dtTable: Could not convert '0' to a string.
       at javax.faces.convert.IntegerConverter.getAsString(IntegerConverter.java:151)
       at org.ajax4jsf.component.UIDataAdaptor.getClientId(UIDataAdaptor.java:715)
       at javax.faces.component.UIComponent.getContainerClientId(UIComponent.java:374)
       at javax.faces.component.UIComponentBase.getClientId(UIComponentBase.java:279)
       at org.ajax4jsf.component.UIDataAdaptor.restoreChildState(UIDataAdaptor.java:964)
       at org.ajax4jsf.component.UIDataAdaptor.restoreChildState(UIDataAdaptor.java:986)
       at org.ajax4jsf.component.UIDataAdaptor.restoreChildState(UIDataAdaptor.java:943)
       at org.ajax4jsf.component.UIDataAdaptor.setRowKey(UIDataAdaptor.java:361)
       at org.ajax4jsf.component.UIDataAdaptor$ComponentVisitor.process(UIDataAdaptor.java:95)
       at org.richfaces.model.ExtendedTableDataModel.walk(ExtendedTableDataModel.java:183)
       at org.ajax4jsf.component.UIDataAdaptor.walk(UIDataAdaptor.java:1151)
       at org.ajax4jsf.component.UIDataAdaptor.iterate(UIDataAdaptor.java:1042)
       ... 40 more
      Caused by: java.lang.ClassCastException: com.tsystems.eurojet.ejfin.de.DisplayableKey cannot be cast to java.lang.Number
       at javax.faces.convert.IntegerConverter.getAsString(IntegerConverter.java:149)
       ... 51 more
      

      With rich:extendedDataTable no problem.

      What could be wrong here?

      thanks a lot
      Dmitri