jsf - primefaces rowEdit Event to update table only if the event is a success -
i calling rowedit event , want refresh table when event performs db update successfully. below code.
xhtml
<p:datatable id="xobjtable" var="xobj" value="#{xlistview.xlistresponseobject}" scrollrows="20" scrollable="true" livescroll="true" scrollheight="600" rowkey="#{xobj.x}" selection="#{xlistview.selectedobject}" selectionmode="single" style="margin-top: 20px; margin-bottom:20px" editable="true"> <f:facet name="header"> search results <p:spacer width="20"/> <h:commandlink id="csv"> <p:graphicimage value="csv.png" width="24"/> <p:dataexporter type="csv" target="xobj" filename="xlistsearch" /> <p:tooltip id="tooltipfade" for="csv" value="click on csv download entire table csv file. " /> </h:commandlink> </f:facet> <p:ajax event="rowedit" listener="#{xlistview.onrowedit}" update=":xlistform:xobjtable" /> <p:column headertext="x" style="width:60px;text-align: center"> <h:outputtext value="#{xobj.x}" /> </p:column> <p:column headertext="y" style="width:60px;text-align: center"> <h:outputtext value="#{xobj.y}" /> </p:column> <p:column headertext="modified date" style="width:160px;text-align: center"> <h:outputtext value="#{xobj.modifieddate}" /> </p:column> <p:column headertext="active" style="width:160px;text-align: center"> <p:celleditor> <f:facet name="output"> <h:outputtext value="#{xobj.active}"/> </f:facet> <f:facet name="input"> <h:selectonemenu value="#{xobj.active}"> <f:selectitems value="#{xlistview.activelist}" /> </h:selectonemenu> </f:facet> </p:celleditor> </p:column> <p:column headertext="location" style="width:160px;text-align: center"> <p:celleditor> <f:facet name="output"> <h:outputtext value="#{xobj.location}"/> </f:facet> <f:facet name="input"> <p:inputtext id="location" value="#{xobj.location}" /> </f:facet> </p:celleditor> </p:column> <p:column headertext="state" style="width:160px;text-align: center"> <p:celleditor> <f:facet name="output"> <h:outputtext value="#{xobj.state}"/> </f:facet> <f:facet name="input"> <p:inputtext id="state" value="#{xobj.state}" /> </f:facet> </p:celleditor> </p:column> <p:column headertext="x country code" style="width:160px;text-align: center"> <p:celleditor> <f:facet name="output"> <h:outputtext value="#{xobj.xcountrycode}"/> </f:facet> <f:facet name="input"> <p:inputtext id="xcountrycode" value="#{xobj.xcountrycode}" /> </f:facet> </p:celleditor> </p:column> <p:column headertext="xrarier" style="width:160px;text-align: center"> <p:celleditor> <f:facet name="output"> <h:outputtext value="#{xobj.carrier}"/> </f:facet> <f:facet name="input"> <h:selectonemenu value="#{xobj.carrier}"> <f:selectitems value="#{xlistview.xarrierlist}" /> </h:selectonemenu> </f:facet> </p:celleditor> </p:column> <p:column style="width:32px" headertext="edit" rendered="#{alltabs.isshow(xlistview.title)}"> <p:roweditor /> </p:column> <p:column style="width:160px;text-align: center" rendered="#{alltabs.isshow(xlistview.title)}" headertext="delete"> <p:commandbutton id="deletedid" actionlistener="#{xlistview.deletexy(xobj)}" icon="ui-icon ui-icon-trash red" title="delete" update="@form"> <p:confirm header="confirmation" message="#{xlistview.finaldeletemessage}" icon="ui-icon-alert" /> </p:commandbutton> </p:column> </p:datatable>
here event method
public void onrowedit(roweditevent event) { xlistresponseobject editobject = (xlistresponseobject) event.getobject(); logger.debug("coming edit row."); string editxystatus = xlistdao.editxy(editobject); if (editxystatus.equals(success_response)) { facesmessage msg = new facesmessage(facesmessage.severity_info, "info", "x/y edit successful!"); facescontext.getcurrentinstance().addmessage(null, msg); } else { facesmessage msg = new facesmessage(facesmessage.severity_error, "info", "x/y edit failed :" + editxystatus); facescontext.getcurrentinstance().addmessage(null, msg); } }
i update happen when rowedit event updates db. can have boolean set in method , access data in update in p:ajax ?
add end of success_response
requestcontext.getcurrentinstance().update("form:npaobjtable");
or whatever table real id is.
Comments
Post a Comment