jsf - java.lang.UnsupportedOperationException: getRowData(String rowKey) must be implemented when basic rowKey algorithm is not used -


i have upgraded primefaces 5.1 final 5.2 final (the community release). have <p:datatable> lazily loaded follows (a minimal example reproduce problem pure testing purpose only).

<p:datatable  var="row"               value="#{testmanagedbean}"               lazy="true"               editable="true"               rowkey="#{row.fruitid}"               selection="#{testmanagedbean.selectedvalues}"               rows="50">      <p:column selectionmode="multiple"/>      <p:ajax event="rowedit" listener="#{testmanagedbean.onrowedit}"/>      <p:column headertext="id">         <h:outputtext value="#{row.fruitid}"/>     </p:column>      <p:column headertext="fruit name">         <p:celleditor>             <f:facet name="output">                 <h:outputtext value="#{row.fruitname}"/>             </f:facet>             <f:facet name="input">                 <p:inputtext value="#{row.fruitname}"/>             </f:facet>         </p:celleditor>     </p:column>      <p:column headertext="price">         <p:celleditor>             <f:facet name="output">                 <h:outputtext value="#{row.price}"/>             </f:facet>             <f:facet name="input">                 <p:inputtext value="#{row.price}"/>             </f:facet>         </p:celleditor>     </p:column>      <p:column headertext="edit">         <p:roweditor/>     </p:column> </p:datatable> 

the corresponding managed bean :

@named @viewscoped public class testmanagedbean extends lazydatamodel<fruit>  implements serializable {      private list<fruit> selectedvalues; // getter & setter.     private static final long serialversionuid = 1l;      public testmanagedbean() {}      private list<fruit> init() {         list<fruit> fruits = new arraylist<fruit>();          fruit fruit = new fruit();         fruit.setfruitid(1);         fruit.setfruitname("mango");         fruit.setprice(500d);         fruits.add(fruit);          fruit = new fruit();         fruit.setfruitid(2);         fruit.setfruitname("guava");         fruit.setprice(300d);         fruits.add(fruit);          fruit = new fruit();         fruit.setfruitid(3);         fruit.setfruitname("apple");         fruit.setprice(600d);         fruits.add(fruit);         return fruits;     }      @override     public list<fruit> load(int first, int pagesize, string sortfield, sortorder sortorder, map<string, object> filters) {         list<fruit> fruits = init();         setrowcount(fruits.size());         return fruits;     }      public void onrowedit(roweditevent event) {         system.out.println("id : "+((fruit)event.getobject()).getfruitid());     } } 

while editing onrowedit() method supposed invoked bound to,

<p:ajax event="rowedit" listener="#{testmanagedbean.onrowedit}"/> 

when row in edit mode , update link marked tick clicked, causes following exception thrown.

info:   java.lang.unsupportedoperationexception: getrowdata(string rowkey) must implemented when basic rowkey algorithm not used. java.lang.unsupportedoperationexception: getrowdata(string rowkey) must implemented when basic rowkey algorithm not used.     @ org.primefaces.model.lazydatamodel.getrowdata(lazydatamodel.java:95)     @ org.primefaces.component.datatable.datatable.getrowdata(datatable.java:1214)     @ org.primefaces.component.datatable.feature.selectionfeature.decodemultipleselection(selectionfeature.java:90)     @ org.primefaces.component.datatable.feature.selectionfeature.decode(selectionfeature.java:48)     @ org.primefaces.component.datatable.datatablerenderer.decode(datatablerenderer.java:62)     @ javax.faces.component.uicomponentbase.decode(uicomponentbase.java:834)     @ org.primefaces.component.api.uidata.processdecodes(uidata.java:281)     @ com.sun.faces.context.partialviewcontextimpl$phaseawarevisitcallback.visit(partialviewcontextimpl.java:573)     @ com.sun.faces.component.visit.partialvisitcontext.invokevisitcallback(partialvisitcontext.java:183)     @ org.primefaces.component.api.uidata.visittree(uidata.java:821)     @ javax.faces.component.uicomponent.visittree(uicomponent.java:1690)     @ javax.faces.component.uiform.visittree(uiform.java:380)     @ javax.faces.component.uicomponent.visittree(uicomponent.java:1690)     @ javax.faces.component.uicomponent.visittree(uicomponent.java:1690)     @ com.sun.faces.context.partialviewcontextimpl.processcomponents(partialviewcontextimpl.java:403)     @ com.sun.faces.context.partialviewcontextimpl.processpartial(partialviewcontextimpl.java:266)     @ org.primefaces.context.primepartialviewcontext.processpartial(primepartialviewcontext.java:60)     @ javax.faces.component.uiviewroot.processdecodes(uiviewroot.java:930)     @ com.sun.faces.lifecycle.applyrequestvaluesphase.execute(applyrequestvaluesphase.java:78)     @ com.sun.faces.lifecycle.phase.dophase(phase.java:101)     @ com.sun.faces.lifecycle.lifecycleimpl.execute(lifecycleimpl.java:198)     @ javax.faces.webapp.facesservlet.service(facesservlet.java:660)     @ org.apache.catalina.core.standardwrapper.service(standardwrapper.java:1682)     @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:318)     @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:160)     @ org.apache.catalina.core.standardpipeline.doinvoke(standardpipeline.java:734)     @ org.apache.catalina.core.standardpipeline.invoke(standardpipeline.java:673)     @ com.sun.enterprise.web.webpipeline.invoke(webpipeline.java:99)     @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:174)     @ org.apache.catalina.connector.coyoteadapter.doservice(coyoteadapter.java:415)     @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:282)     @ com.sun.enterprise.v3.services.impl.containermapper$httphandlercallable.call(containermapper.java:459)     @ com.sun.enterprise.v3.services.impl.containermapper.service(containermapper.java:167)     @ org.glassfish.grizzly.http.server.httphandler.runservice(httphandler.java:201)     @ org.glassfish.grizzly.http.server.httphandler.dohandle(httphandler.java:175)     @ org.glassfish.grizzly.http.server.httpserverfilter.handleread(httpserverfilter.java:235)     @ org.glassfish.grizzly.filterchain.executorresolver$9.execute(executorresolver.java:119)     @ org.glassfish.grizzly.filterchain.defaultfilterchain.executefilter(defaultfilterchain.java:284)     @ org.glassfish.grizzly.filterchain.defaultfilterchain.executechainpart(defaultfilterchain.java:201)     @ org.glassfish.grizzly.filterchain.defaultfilterchain.execute(defaultfilterchain.java:133)     @ org.glassfish.grizzly.filterchain.defaultfilterchain.process(defaultfilterchain.java:112)     @ org.glassfish.grizzly.processorexecutor.execute(processorexecutor.java:77)     @ org.glassfish.grizzly.nio.transport.tcpniotransport.fireioevent(tcpniotransport.java:561)     @ org.glassfish.grizzly.strategies.abstractiostrategy.fireioevent(abstractiostrategy.java:112)     @ org.glassfish.grizzly.strategies.workerthreadiostrategy.run0(workerthreadiostrategy.java:117)     @ org.glassfish.grizzly.strategies.workerthreadiostrategy.access$100(workerthreadiostrategy.java:56)     @ org.glassfish.grizzly.strategies.workerthreadiostrategy$workerthreadrunnable.run(workerthreadiostrategy.java:137)     @ org.glassfish.grizzly.threadpool.abstractthreadpool$worker.dowork(abstractthreadpool.java:565)     @ org.glassfish.grizzly.threadpool.abstractthreadpool$worker.run(abstractthreadpool.java:545)     @ java.lang.thread.run(thread.java:745)  warning:   java.lang.unsupportedoperationexception: getrowdata(string rowkey) must implemented when basic rowkey algorithm not used. javax.faces.facesexception: java.lang.unsupportedoperationexception: getrowdata(string rowkey) must implemented when basic rowkey algorithm not used.     @ com.sun.faces.context.partialviewcontextimpl.processpartial(partialviewcontextimpl.java:273)     @ org.primefaces.context.primepartialviewcontext.processpartial(primepartialviewcontext.java:60)     @ javax.faces.component.uiviewroot.processdecodes(uiviewroot.java:930)     @ com.sun.faces.lifecycle.applyrequestvaluesphase.execute(applyrequestvaluesphase.java:78)     @ com.sun.faces.lifecycle.phase.dophase(phase.java:101)     @ com.sun.faces.lifecycle.lifecycleimpl.execute(lifecycleimpl.java:198)     @ javax.faces.webapp.facesservlet.service(facesservlet.java:660)     @ org.apache.catalina.core.standardwrapper.service(standardwrapper.java:1682)     @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:318)     @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:160)     @ org.apache.catalina.core.standardpipeline.doinvoke(standardpipeline.java:734)     @ org.apache.catalina.core.standardpipeline.invoke(standardpipeline.java:673)     @ com.sun.enterprise.web.webpipeline.invoke(webpipeline.java:99)     @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:174)     @ org.apache.catalina.connector.coyoteadapter.doservice(coyoteadapter.java:415)     @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:282)     @ com.sun.enterprise.v3.services.impl.containermapper$httphandlercallable.call(containermapper.java:459)     @ com.sun.enterprise.v3.services.impl.containermapper.service(containermapper.java:167)     @ org.glassfish.grizzly.http.server.httphandler.runservice(httphandler.java:201)     @ org.glassfish.grizzly.http.server.httphandler.dohandle(httphandler.java:175)     @ org.glassfish.grizzly.http.server.httpserverfilter.handleread(httpserverfilter.java:235)     @ org.glassfish.grizzly.filterchain.executorresolver$9.execute(executorresolver.java:119)     @ org.glassfish.grizzly.filterchain.defaultfilterchain.executefilter(defaultfilterchain.java:284)     @ org.glassfish.grizzly.filterchain.defaultfilterchain.executechainpart(defaultfilterchain.java:201)     @ org.glassfish.grizzly.filterchain.defaultfilterchain.execute(defaultfilterchain.java:133)     @ org.glassfish.grizzly.filterchain.defaultfilterchain.process(defaultfilterchain.java:112)     @ org.glassfish.grizzly.processorexecutor.execute(processorexecutor.java:77)     @ org.glassfish.grizzly.nio.transport.tcpniotransport.fireioevent(tcpniotransport.java:561)     @ org.glassfish.grizzly.strategies.abstractiostrategy.fireioevent(abstractiostrategy.java:112)     @ org.glassfish.grizzly.strategies.workerthreadiostrategy.run0(workerthreadiostrategy.java:117)     @ org.glassfish.grizzly.strategies.workerthreadiostrategy.access$100(workerthreadiostrategy.java:56)     @ org.glassfish.grizzly.strategies.workerthreadiostrategy$workerthreadrunnable.run(workerthreadiostrategy.java:137)     @ org.glassfish.grizzly.threadpool.abstractthreadpool$worker.dowork(abstractthreadpool.java:565)     @ org.glassfish.grizzly.threadpool.abstractthreadpool$worker.run(abstractthreadpool.java:545)     @ java.lang.thread.run(thread.java:745) caused by: java.lang.unsupportedoperationexception: getrowdata(string rowkey) must implemented when basic rowkey algorithm not used.     @ org.primefaces.model.lazydatamodel.getrowdata(lazydatamodel.java:95)     @ org.primefaces.component.datatable.datatable.getrowdata(datatable.java:1214)     @ org.primefaces.component.datatable.feature.selectionfeature.decodemultipleselection(selectionfeature.java:90)     @ org.primefaces.component.datatable.feature.selectionfeature.decode(selectionfeature.java:48)     @ org.primefaces.component.datatable.datatablerenderer.decode(datatablerenderer.java:62)     @ javax.faces.component.uicomponentbase.decode(uicomponentbase.java:834)     @ org.primefaces.component.api.uidata.processdecodes(uidata.java:281)     @ com.sun.faces.context.partialviewcontextimpl$phaseawarevisitcallback.visit(partialviewcontextimpl.java:573)     @ com.sun.faces.component.visit.partialvisitcontext.invokevisitcallback(partialvisitcontext.java:183)     @ org.primefaces.component.api.uidata.visittree(uidata.java:821)     @ javax.faces.component.uicomponent.visittree(uicomponent.java:1690)     @ javax.faces.component.uiform.visittree(uiform.java:380)     @ javax.faces.component.uicomponent.visittree(uicomponent.java:1690)     @ javax.faces.component.uicomponent.visittree(uicomponent.java:1690)     @ com.sun.faces.context.partialviewcontextimpl.processcomponents(partialviewcontextimpl.java:403)     @ com.sun.faces.context.partialviewcontextimpl.processpartial(partialviewcontextimpl.java:266)     ... 34 more  severe:   java.lang.unsupportedoperationexception: getrowdata(string rowkey) must implemented when basic rowkey algorithm not used.     @ org.primefaces.model.lazydatamodel.getrowdata(lazydatamodel.java:95)     @ org.primefaces.component.datatable.datatable.getrowdata(datatable.java:1214)     @ org.primefaces.component.datatable.feature.selectionfeature.decodemultipleselection(selectionfeature.java:90)     @ org.primefaces.component.datatable.feature.selectionfeature.decode(selectionfeature.java:48)     @ org.primefaces.component.datatable.datatablerenderer.decode(datatablerenderer.java:62)     @ javax.faces.component.uicomponentbase.decode(uicomponentbase.java:834)     @ org.primefaces.component.api.uidata.processdecodes(uidata.java:281)     @ com.sun.faces.context.partialviewcontextimpl$phaseawarevisitcallback.visit(partialviewcontextimpl.java:573)     @ com.sun.faces.component.visit.partialvisitcontext.invokevisitcallback(partialvisitcontext.java:183)     @ org.primefaces.component.api.uidata.visittree(uidata.java:821)     @ javax.faces.component.uicomponent.visittree(uicomponent.java:1690)     @ javax.faces.component.uiform.visittree(uiform.java:380)     @ javax.faces.component.uicomponent.visittree(uicomponent.java:1690)     @ javax.faces.component.uicomponent.visittree(uicomponent.java:1690)     @ com.sun.faces.context.partialviewcontextimpl.processcomponents(partialviewcontextimpl.java:403)     @ com.sun.faces.context.partialviewcontextimpl.processpartial(partialviewcontextimpl.java:266)     @ org.primefaces.context.primepartialviewcontext.processpartial(primepartialviewcontext.java:60)     @ javax.faces.component.uiviewroot.processdecodes(uiviewroot.java:930)     @ com.sun.faces.lifecycle.applyrequestvaluesphase.execute(applyrequestvaluesphase.java:78)     @ com.sun.faces.lifecycle.phase.dophase(phase.java:101)     @ com.sun.faces.lifecycle.lifecycleimpl.execute(lifecycleimpl.java:198)     @ javax.faces.webapp.facesservlet.service(facesservlet.java:660)     @ org.apache.catalina.core.standardwrapper.service(standardwrapper.java:1682)     @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:318)     @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:160)     @ org.apache.catalina.core.standardpipeline.doinvoke(standardpipeline.java:734)     @ org.apache.catalina.core.standardpipeline.invoke(standardpipeline.java:673)     @ com.sun.enterprise.web.webpipeline.invoke(webpipeline.java:99)     @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:174)     @ org.apache.catalina.connector.coyoteadapter.doservice(coyoteadapter.java:415)     @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:282)     @ com.sun.enterprise.v3.services.impl.containermapper$httphandlercallable.call(containermapper.java:459)     @ com.sun.enterprise.v3.services.impl.containermapper.service(containermapper.java:167)     @ org.glassfish.grizzly.http.server.httphandler.runservice(httphandler.java:201)     @ org.glassfish.grizzly.http.server.httphandler.dohandle(httphandler.java:175)     @ org.glassfish.grizzly.http.server.httpserverfilter.handleread(httpserverfilter.java:235)     @ org.glassfish.grizzly.filterchain.executorresolver$9.execute(executorresolver.java:119)     @ org.glassfish.grizzly.filterchain.defaultfilterchain.executefilter(defaultfilterchain.java:284)     @ org.glassfish.grizzly.filterchain.defaultfilterchain.executechainpart(defaultfilterchain.java:201)     @ org.glassfish.grizzly.filterchain.defaultfilterchain.execute(defaultfilterchain.java:133)     @ org.glassfish.grizzly.filterchain.defaultfilterchain.process(defaultfilterchain.java:112)     @ org.glassfish.grizzly.processorexecutor.execute(processorexecutor.java:77)     @ org.glassfish.grizzly.nio.transport.tcpniotransport.fireioevent(tcpniotransport.java:561)     @ org.glassfish.grizzly.strategies.abstractiostrategy.fireioevent(abstractiostrategy.java:112)     @ org.glassfish.grizzly.strategies.workerthreadiostrategy.run0(workerthreadiostrategy.java:117)     @ org.glassfish.grizzly.strategies.workerthreadiostrategy.access$100(workerthreadiostrategy.java:56)     @ org.glassfish.grizzly.strategies.workerthreadiostrategy$workerthreadrunnable.run(workerthreadiostrategy.java:137)     @ org.glassfish.grizzly.threadpool.abstractthreadpool$worker.dowork(abstractthreadpool.java:565)     @ org.glassfish.grizzly.threadpool.abstractthreadpool$worker.run(abstractthreadpool.java:545)     @ java.lang.thread.run(thread.java:745) 

this should not happen because rowkey="#{row.fruitid}" used given <p:datatable>.

the exception disappears when rowkey attribute removed , getrowkey() , getrowdata() methods implemented in associated managed bean follows.

@override public object getrowkey(fruit fruit) {     return fruit != null ? fruit.getfruitid() : null; }  @override public fruit getrowdata(string rowkey) {     list<fruit> fruits = (list<fruit>) getwrappeddata();     integer value = integer.valueof(rowkey);      (fruit fruit : fruits) {         if (fruit.getfruitid().equals(value)) {             return fruit;         }     }      return null; } 

is mandatory in newest version of primefaces (5.2 final) not needed in previous version of primefaces (5.1 final)?

tested on mojarra 2.3.0-m02. presumed there should not relevance version of mojarra.

as mentioned in this link pointing primefaces community forum,

we changed part design cause rowkey attribute handling lazydatamodel not correct.

those 2 methods getrowkey() , getrowdata() need implemented in associated managed bean whenever lazydatamodel<t> used shown in question.

from primefaces user guide (pdf) - (5.1 (page 164) , 5.2 (page 166)) :

lazy loading approach deal huge datasets efficiently, regular ajax based pagination works rendering particular page still requires data loaded memory. lazy loading datatable renders particular page loads page data memory not whole dataset. in order implement this, you’d need bind org.primefaces.model.lazydatamodel value , implement load method , enable lazy option. also required implement getrowdata , getrowkey if have selection enabled.


the attribute rowkey may used, when lazy disabled -- set false (default) , row selection enabled.

from primefaces user guide (pdf) - (5.1 (page 159) , 5.2 (page 161)) :

rowkey should unique identifier data model , used datatable find selected rows. can either define key using rowkey attribute or binding data model implements org.primefaces.model.selectabledatamodel.

such as,

<p:datatable var="car"              value="#{carbean.cars}"              selection="#{carbean.selectedcars}"              rowkey="#{car.id}">      <p:column selectionmode="multiple"/>     <!--columns--> </p:datatable> 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -