primefaces datatable filterBy, sortBy and pagination options not working -
i using primefaces3.3 version. have datatable show details , crud buttons part of footer of datatable. dialog shown on click of crud buttons after selecting particular row in datatable.
when click on save button in dialog , data saved , datatable refreshed. however, sortby , pagination options not working after this. along datatable's selection mode changed multiple. behavior reproducable in ie 8 , ff 12. works fine in google chrome 19. both xhtml , backing bean code attached.
account.xhtml
<h:head> <script type="text/javascript"> function handledialogsubmit(xhr, status, args) { if (args != null) { if (args.validationfailed) { accountdialog.show(); return true; } else { accountdialog.hide(); return true; } } } </script> </h:head> <h:body> <ui:composition template="/template.xhtml"> <ui:define name="body"> <h:form id="form" prependid="false"> <p:contextmenu for="datatable"> <p:menuitem value="view" update=":form2:accountdisplay" icon="ui-icon-search" oncomplete="accountdialog.show()" process="@this"> <f:setpropertyactionlistener value="#{account}" target="#{accountbean.selectedaccount}" /> </p:menuitem> <p:menuitem value="edit" update=":form2:accountdisplay" icon="ui-icon-edit" oncomplete="accountdialog.show()" process="@this" immedeate="true"> <f:setpropertyactionlistener value="#{account}" target="#{accountbean.currentaccount}" /> </p:menuitem> <p:menuitem value="delete" update=":dialogform:confirmdialog" icon="ui-icon-close" oncomplete="confirmation.show()" /> </p:contextmenu> <h:panelgroup id="datapanel"> <p:datatable var="account" value="#{accountbean.accounts}" paginator="true" rows="20" rowkey="#{account.accountcode}" paginatortemplate="{currentpagereport} {firstpagelink} {previouspagelink} {pagelinks} {nextpagelink} {lastpagelink} {rowsperpagedropdown}" id="datatable"> <p:column headertext="edit|view|delete"> <p:commandlink id="selectbutton1" update=":form2:accountdisplay" title="edit" process="@this" oncomplete="accountdialog.show()"> <h:outputtext value="edit" /> <f:setpropertyactionlistener value="#{account}" target="#{accountbean.currentaccount}" /> </p:commandlink> | <p:commandlink id="detailbutton1" update=":form2:accountdisplay" title="view details" oncomplete="accountdialog.show()" process="@this"> <h:outputtext value="view" /> <f:setpropertyactionlistener value="#{account}" target="#{accountbean.selectedaccount}" /> </p:commandlink> | <p:commandlink id="showdialogbutton1" update=":dialogform:confirmdialog" title="delete" oncomplete="confirmation.show()" process="@this"> <h:outputtext value="delete" /> <f:setpropertyactionlistener value="#{account}" target="#{accountbean.selectedaccount}" /> </p:commandlink> </p:column> <p:column id="accountcode" headertext=" account code" sortby="#{account.accountcode}" filterby="#{account.accountcode}" filtermatchmode="startswith" footertext="startswith"> <h:outputtext value="#{account.accountcode}" /> </p:column> <p:column id="alertcode" headertext=" alert code" sortby="#{account.alertcode}" filterby="#{account.alertcode}" filtermatchmode="contains" footertext="contains"> <h:outputtext value="#{account.alertcode}" /> </p:column> <p:column id="clearagentid" headertext=" clr agent#" sortby="#{account.clearagentid}" filterby="#{account.clearagentid}" filtermatchmode="startswith" footertext="startswith"> <h:outputtext value="#{account.clearagentid}" /> </p:column> <p:column id="globalaccountnum" headertext=" global acct#" sortby="#{account.globalaccountnum}" filterby="#{account.globalaccountnum}" filtermatchmode="startswith" footertext="startswith"> <h:outputtext value="#{account.globalaccountnum}" /> </p:column> <p:column id="safekeepingaccountnum" headertext=" safekeeping acct#" sortby="#{account.safekeepingaccountnum}" filterby="#{account.safekeepingaccountnum}" filtermatchmode="startswith" footertext="startswith"> <h:outputtext value="#{account.safekeepingaccountnum}" /> </p:column> <p:column id="destinationid" headertext=" primary dest id" sortby="#{account.destinationid}" filterby="#{account.destinationid}" filtermatchmode="startswith" footertext="startswith"> <h:outputtext value="#{account.destinationid}" /> </p:column> <p:column id="addldestinationid1" headertext=" addl dest id1" sortby="#{account.addldestinationid1}" filterby="#{account.addldestinationid1}" filtermatchmode="startswith" footertext="startswith"> <h:outputtext value="#{account.addldestinationid1}" /> </p:column> <p:column id="addldestinationid2" headertext=" addl dest id2" sortby="#{account.addldestinationid2}" filterby="#{account.addldestinationid2}" filtermatchmode="startswith" footertext="startswith"> <h:outputtext value="#{account.addldestinationid2}" /> </p:column> <p:column id="addldestinationid3" headertext=" addl dest id3" sortby="#{account.addldestinationid3}" filterby="#{account.addldestinationid3}" filtermatchmode="startswith" footertext="startswith"> <h:outputtext value="#{account.addldestinationid3}" /> </p:column> <p:column id="destinationname" headertext=" primary dest name" sortby="#{account.destinationname}" filterby="#{account.destinationname}" filtermatchmode="startswith" footertext="startswith"> <h:outputtext value="#{account.destinationname}" /> </p:column> <p:column id="conbic" headertext=" cont bic" sortby="#{account.conbic}" filterby="#{account.conbic}" filtermatchmode="startswith" footertext="startswith"> <h:outputtext value="#{account.conbic}" /> </p:column> <p:column id="accountstatus" headertext=" status" sortby="#{account.accountstatus}" filteroptions="#{account.accountstatus}" filtermatchmode="exact" footertext="exact"> <h:outputtext value="#{account.accountstatus}" /> </p:column> <p:column id="comments" headertext="comments" sortby="#{account.comments}" filterby="#{account.comments}" filtermatchmode="startswith" footertext="startswith"> <h:outputtext value="#{account.comments}" /> </p:column> <p:column id="createdby" headertext=" created by" sortby="#{account.createdby}" filterby="#{account.createdby}" filtermatchmode="startswith" footertext="startswith"> <h:outputtext value="#{account.createdby}" /> </p:column> <p:column id="createddate" headertext=" created date" sortby="#{account.createddate}" filterby="#{account.createddate}" filtermatchmode="startswith" footertext="startswith"> <h:outputtext value="#{account.createddate}" /> </p:column> <p:column id="modifiedby" headertext=" modified by" sortby="#{account.modifiedby}" filterby="#{account.modifiedby}" filtermatchmode="startswith" footertext="startswith"> <h:outputtext value="#{account.modifiedby}" /> </p:column> <p:column id="modifieddate" headertext=" modified date" sortby="#{account.modifieddate}" filterby="#{account.modifieddate}" filtermatchmode="startswith" footertext="startswith"> <h:outputtext value="#{account.modifieddate}" /> </p:column> <!-- <f:facet name="footer"> <p:toolbar> <p:toolbargroup align="left"> <p:tooltip for="btnadd" value="add new account" /> <p:commandbutton id="btnrefresh" styleclass="refreshbutton" title="refresh account information" value="refresh" icon="ui-icon-refresh" actionlistener="#{accountbean.populateaccounts}" update=":form:datatable,:form2:display" immediate="true"/> <p:tooltip for="btnrefresh" value="refresh account details" /> <p:commandbutton id="selectbutton" update=":form2:accountdisplay" icon="ui-icon-edit" title="edit account details" value="edit" process="@this" oncomplete="accountdialog.show()" immediate="true"> <f:setpropertyactionlistener value="#{account}" target="#{accountbean.currentaccount}" /> </p:commandbutton> <p:commandbutton id="detailbutton" value="view" icon="ui-icon-view" update=":form2:accountdisplay" title="view account details" oncomplete="detaildialog.show()" process="@this" immediate="true"> <f:setpropertyactionlistener value="#{account}" target="#{accountbean.selectedaccount}" /> </p:commandbutton> <p:commandbutton id="showdialogbutton" icon="ui-icon-delete" value="delete" update=":dialogform:confirmdialog" title="delete account details" oncomplete="confirmation.show()" process="@this" immediate="true"> <f:setpropertyactionlistener value="#{account}" target="#{accountbean.selectedaccount}" /> </p:commandbutton> </p:toolbargroup> </p:toolbar> </f:facet> --> <f:facet name="footer"> <p:toolbar> <p:toolbargroup align="left"> <p:commandbutton id="btnadd" value="add" title="add new account" icon="ui-icon-add" oncomplete="accountdialog.show()" /> <p:commandbutton id="editbutton" value="edit" icon="ui-icon-edit" update=":form2:accountdisplay" oncomplete="accountdialog.show()"> </p:commandbutton> <p:commandbutton id="showdialogbutton" icon="ui-icon-delete" value="delete" title="delete account details" oncomplete="confirmation.show()"> </p:commandbutton> <p:commandbutton id="viewbutton" value="view" icon="ui-icon-search" update=":form2:display" oncomplete="accountdialog.show()" /> <p:commandbutton id="btnrefresh" styleclass="refreshbutton" title="refresh account information" value="refresh" icon="ui-icon-refresh" actionlistener="#{accountbean.populateaccounts}" update=":form:datatable"/> </p:toolbargroup> </p:toolbar> </f:facet> </p:datatable> </h:panelgroup> </h:form> <h:form id="form2" > <!-- <p:growl id="growl" showdetail="true" sticky="true" /> --> <p:dialog id="basicdialog" header="account details" widgetvar="detaildialog" resizable="false"> <h:panelgrid id="display" columns="2"> <h:outputtext value="#{bundle.accountlabel_accountcode}" /> <h:outputtext value="#{accountbean.selectedaccount.accountcode}" title="#{bundle.accounttitle_accountcode}" /> <h:outputtext value="#{bundle.accountlabel_alertcode}" /> <h:outputtext value="#{accountbean.selectedaccount.alertcode}" title="#{bundle.accounttitle_alertcode}" /> <h:outputtext value="#{bundle.accountlabel_clearagentid}" /> <h:outputtext value="#{accountbean.selectedaccount.clearagentid}" title="#{bundle.accounttitle_clearagentid}" /> <h:outputtext value="#{bundle.accountlabel_globalaccountnum}" /> <h:outputtext value="#{accountbean.selectedaccount.globalaccountnum}" title="#{bundle.accounttitle_globalaccountnum}" /> <h:outputtext value="#{bundle.accountlabel_safekeepingaccountnum}" /> <h:outputtext value="#{accountbean.selectedaccount.safekeepingaccountnum}" title="#{bundle.accounttitle_safekeepingaccountnum}" /> <h:outputtext value="#{bundle.accountlabel_destinationid}" /> <h:outputtext value="#{accountbean.selectedaccount.destinationid}" title="#{bundle.accounttitle_destinationid}" /> <h:outputtext value="#{bundle.accountlabel_addldestinationid1}" /> <h:outputtext value="#{accountbean.selectedaccount.addldestinationid1}" title="#{bundle.accounttitle_addldestinationid1}" /> <h:outputtext value="#{bundle.accountlabel_addldestinationid2}" /> <h:outputtext value="#{accountbean.selectedaccount.addldestinationid2}" title="#{bundle.accounttitle_addldestinationid2}" /> <h:outputtext value="#{bundle.accountlabel_addldestinationid3}" /> <h:outputtext value="#{accountbean.selectedaccount.addldestinationid3}" title="#{bundle.accounttitle_addldestinationid3}" /> <h:outputtext value="#{bundle.accountlabel_destinationname}" /> <h:outputtext value="#{accountbean.selectedaccount.destinationname}" title="#{bundle.accounttitle_destinationname}" /> <h:outputtext value="#{bundle.accountlabel_conbic}" /> <h:outputtext value="#{accountbean.selectedaccount.conbic}" title="#{bundle.accounttitle_conbic}" /> <h:outputtext value="#{bundle.accountlabel_accountstatus}" /> <h:outputtext value="#{accountbean.selectedaccount.accountstatus}" title="#{bundle.accounttitle_accountstatus}" /> <h:outputtext value="#{bundle.accountlabel_comments}" /> <h:outputtext value="#{accountbean.selectedaccount.comments}" title="#{bundle.accounttitle_comments}" /> <h:outputtext value="#{bundle.accountlabel_createdby}" /> <h:outputtext value="#{accountbean.selectedaccount.createdby}" title="#{bundle.accounttitle_createdby}" /> <h:outputtext value="#{bundle.accountlabel_createddate}" /> <h:outputtext value="#{accountbean.selectedaccount.createddate}" title="#{bundle.accounttitle_createddate}" /> <h:outputtext value="#{bundle.accountlabel_modifiedby}" /> <h:outputtext value="#{accountbean.selectedaccount.modifiedby}" title="#{bundle.accounttitle_modifiedby}" /> <h:outputtext value="#{bundle.accountlabel_modifieddate}" /> <h:outputtext value="#{accountbean.selectedaccount.modifieddate}" title="#{bundle.accounttitle_modifieddate}" /> </h:panelgrid> </p:dialog> <p:dialog header="account detail" widgetvar="accountdialog" resizable="false" height="600" width="600" showeffect="clip" hideeffect="fold" id="accountdialog" > <p:messages id="messages" autoupdate="true" /> <h:panelgrid id="accountdisplay" columns="2" cellpadding="4"> <h:outputlabel value="account code:" for="accountcode" /> <p:inputtext label="account code" id="accountcode" value="#{accountbean.currentaccount.accountcode}" title="account code" required="true" validatormessage="#{bundle.accountvalidationaccountcode}" requiredmessage="#{bundle.accountrequiredmessage_accountcode}"> </p:inputtext> <h:outputlabel value="alert code:" for="alertcode" /> <p:inputtext label="alert code" id="alertcode" value="#{accountbean.currentaccount.alertcode}" title="alert code" required="true" validatormessage="#{bundle.accountvalidationalertcode}" requiredmessage="#{bundle.accountrequiredmessage_alertcode}"> </p:inputtext> <h:outputlabel value="clr agent#:" for="clearagentid" /> <p:inputtext label="clr agent#" id="clragent" value="#{accountbean.currentaccount.clearagentid}" title="clr agent#" required="true" requiredmessage="#{bundle.accountrequiredmessage_clearagentid}"> </p:inputtext> <h:outputlabel value="global acct#:" for="globalaccountnum" /> <p:inputtext label="global acct#" id="globalaccountnum" value="#{accountbean.currentaccount.globalaccountnum}" title="global acct#" required="true" requiredmessage="#{bundle.accountrequiredmessage_globalaccountnum}"> </p:inputtext> <h:outputlabel value="safekeeping acct#:" for="safekeepingaccountnum" /> <p:inputtext label="safekeeping account number" id="safekeepingaccountnum" value="#{accountbean.currentaccount.safekeepingaccountnum}" title="safekeeping account number" required="true" validatormessage="#{bundle.accountvalidationsafekeepingaccountnum}" requiredmessage="#{bundle.accountrequiredmessage_safekeepingaccountnum}"> </p:inputtext> <h:outputlabel value="primary dest id:" for="destinationid" /> <p:inputtext label="primary dest id" id="destinationid" value="#{accountbean.currentaccount.destinationid}" title="primary dest id" required="true" requiredmessage="#{bundle.accountrequiredmessage_destinationid}"> </p:inputtext> <h:outputlabel value="addl dest id1:" for="addldestinationid1" /> <p:inputtext label="addl dest id1" id="addldestinationid1" value="#{accountbean.currentaccount.addldestinationid1}" title="addl dest id1" required="true" requiredmessage="#{bundle.accountrequiredmessage_addldestinationid1}"> </p:inputtext> <h:outputlabel value="addl dest id2:" for="addldestinationid2" /> <p:inputtext label="addl dest id2" id="addldestinationid2" value="#{accountbean.currentaccount.addldestinationid2}" title="addl dest id2" required="true" requiredmessage="#{bundle.accountrequiredmessage_addldestinationid2}"> </p:inputtext> <h:outputlabel value="addl dest id3:" for="addldestinationid3" /> <p:inputtext label="addl dest id3" id="addldestinationid3" value="#{accountbean.currentaccount.addldestinationid3}" title="addl dest id3" required="true" requiredmessage="#{bundle.accountrequiredmessage_addldestinationid3}"> </p:inputtext> <h:outputlabel value="primary dest name:" for="destinationname" /> <p:inputtext label="primary dest name" id="destinationname" value="#{accountbean.currentaccount.destinationname}" title="primary dest name" required="true" requiredmessage="#{bundle.accountrequiredmessage_destinationname}"> </p:inputtext> <h:outputlabel value="cont bic:" for="conbic" /> <p:inputtext label="cont bic" id="conbictext" value="#{accountbean.currentaccount.conbic}" title="cont bic" required="true" requiredmessage="#{bundle.accountrequiredmessage_conbic}"> </p:inputtext> <h:outputlabel value="status:" for="accountstatus" /> <p:inputtext label="status" id="conbic" value="#{accountbean.currentaccount.accountstatus}" title="status" required="true" requiredmessage="#{bundle.accountrequiredmessage_accountstatus}"> </p:inputtext> <h:outputlabel value="comments:" for="comments" /> <p:inputtextarea id="comments" rows="5" cols="30" maxlength="10" value="#{accountbean.currentaccount.comments}" autoresize="false" required="true" requiredmessage="#{bundle.accountrequiredmessage_comments}"/> <h:outputlabel /> <h:outputlabel /> <!-- <p:separator id="customseparator" style="width:500px;height:1px" /> --> <f:facet name="footer"> <!-- <p:commandbutton value="new" icon="ui-icon-check"/> --> <h:outputlabel /> <p:commandbutton id="save" styleclass="savebutton" value="save" icon="ui-icon-check" actionlistener="#{accountbean.createorupdate}" oncomplete="handledialogsubmit(xhr,status,args);"/> <!-- update=":form:datatable,:form2:display" onsuccess="accountdialog.hide()" ajax="false"/> --> <p:commandbutton id="cancel" actionlistener="#{accountbean.cancel}" styleclass="cancelbutton" value="cancel" icon="ui-icon-cancel" oncomplete="accountdialog.hide()" process="@this"/> <p:commandbutton id="btnrefresh" styleclass="refreshbutton1" title="refresh account information" value="refresh" icon="ui-icon-refresh" actionlistener="#{accountbean.populateaccounts}" update=":form:datatable"/> </f:facet> </h:panelgrid> </p:dialog> </h:form> <h:form id="dialogform"> <p:confirmdialog id="confirmdialog" header="confirm delete account" severity="alert" widgetvar="confirmation"> <f:facet name="message"> <h:outputtext value="delete #{accountbean.selectedaccount.accountcode}?" /> </f:facet> <p:commandbutton id="confirm" value="yes" oncomplete="confirmation.hide()" update=":form:datatable" actionlistener="#{accountbean.remove}" ajax="false"/> <p:commandbutton id="decline" value="no" onclick="confirmation.hide()" type="button" ajax="false"/> </p:confirmdialog> </h:form> </ui:define> </ui:composition> </h:body> </html> accountbean.java
package com.cba.web.beans; import java.io.serializable; import java.util.list; import javax.faces.bean.managedbean; import javax.faces.bean.viewscoped; import javax.faces.component.uicomponent; import javax.faces.component.uiviewroot; import javax.faces.context.facescontext; import javax.faces.event.actionevent; import org.primefaces.context.requestcontext; import com.cba.services.accountservice; import com.cba.utils.jsfutils; import com.cba.utils.servicelocator; import com.cba.web.model.account; @managedbean(name = "accountbean") @viewscoped public class accountbean implements serializable { private transient accountservice accountservice; private list<account> accounts; private account selectedaccount = new account(); private account currentaccount = new account(); public account getselectedaccount() { return selectedaccount; } public void setselectedaccount(account selectedaccount) { this.selectedaccount = selectedaccount; } public account getcurrentaccount() { return currentaccount; } public void setcurrentaccount(account currentaccount) { this.currentaccount = currentaccount; } public accountbean() { populateaccounts(); } public accountservice getaccountservice() { return accountservice; } public void setaccountservice(accountservice accountservice) { this.accountservice = accountservice; } public list<account> getaccounts() { return accounts; } public void populateaccounts() { accountservice = (accountservice) servicelocator.getinstance().getbean( "accountservice"); accounts = accountservice.getaccountdetails(); } public void createorupdate(actionevent e) { try { system.out.println("entering createorupdate in accountbean"); accountservice = (accountservice) servicelocator.getinstance() .getbean("accountservice"); accountservice.updateaccountdetails(currentaccount); currentaccount = new account(); } catch (exception ex) { ex.printstacktrace(); } } public void cancel(actionevent e) { clear(); } public void remove(actionevent e) { try { accountservice = (accountservice) servicelocator.getinstance() .getbean("accountservice"); accountservice.deleteaccountdetails(selectedaccount); selectedaccount = new account(); populateaccounts(); } catch (exception ex) { ex.printstacktrace(); } } public void clear() { currentaccount = new account(); uiviewroot viewroot = facescontext.getcurrentinstance().getviewroot(); uicomponent component1 = viewroot.findcomponent("form2"); jsfutils.clearcomponenthierarchy(component1); } } any input on of great help.
Comments
Post a Comment