jsf 2 - Delete event not updating datatable rows -
in primefaces have confirm dialogue box , when confirm delete button rows in database deleted page not updated. missing not updating page. dialogue box defined below.
<h:form id="searchform"> <p:commandbutton id="showdialogbutton" value="delete data" onclick="confirmation.show()" style="margin:20px" type="button" immediate="true" /> <p:confirmdialog id="confirmdialog" message="are sure want delete data submission?" header="initiating delete process" severity="alert" widgetvar="confirmation"> <p:commandbutton id="confirm" value="yes sure" update=":searchform:rowdatatable" oncomplete="confirmation.hide()" actionlistener="#{mydatabean.deletedata}" immediate="true" ajax="true"/> <p:commandbutton id="decline" value="not yet" onclick="confirmation.hide()" type="button" immediate="true"/> </p:confirmdialog>
in same form have defined datatable
<p:datatable var="row" value="#{mydatabean.entries}" id="rowdatatable" paginator="true" rows="30" paginatortemplate="{currentpagereport} {firstpagelink} {previouspagelink} {pagelinks} {nextpagelink} {lastpagelink} {rowsperpagedropdown}" rowsperpagetemplate="10,20,30" >
which has subtable inside shows data
<p:subtable id="rowsubtable" var="details" value="#{row.data}">
in bean have following action listener. after action listener completed calls load intial view method reload data because of pre render view event have defined.
public list<submissionrow> entries = new arraylist<submissionrow>(); public void loadinitialview() { if (!postback) { list<submission> data = loaddata(); //sort data , build entries list } } @transactional public void deletedata(actionevent actionevent) { submission.deleterows(submissionbean.getsubmission()); entries.clear(); postback = false; }
as there table visible on page reloaded page action listener using external context. way datatable got updated.
Comments
Post a Comment