Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The dialog has to be outside the table. Also, in the delete button you are updating component ":studyPlanEditForm:display". I don't see that component in the snippet. The panel inside the dialog should have id="display", because the dialog needs to be updated.</p> <p>You can see a working example of a similar use casi in primefaces <a href="http://www.primefaces.org/showcase/ui/datatableRowSelectionByColumn.jsf" rel="nofollow">showcase</a>. You only have to replace the dialog that shows content for the confirm message, and add a button that deleted the row. The managed bean already has a reference to the selected row. </p> <p>This is how the delete button would look like </p> <pre><code>&lt;p:column headerText="Delete" width="50" style="text-align:center"&gt; &lt;p:commandButton id="showDialogButton" update=":studyPlanEditForm:display" onclick="cdDialog.show()" value="delete"&gt; &lt;f:setPropertyActionListener value="#{selectedRow}" target="#{bean.selectedRow}" /&gt; &lt;/p:commandButton&gt; &lt;/p:column&gt; </code></pre> <p>And this is the dialog (has to be outside table):</p> <pre><code>&lt;p:dialog widgetVar="cdDialog" appendToBody="true" header="Are you sure to delete this substudyplan?"&gt; &lt;p:panel id="display"&gt; &lt;p:commandButton value="Yes" process="@this" action="#{editBean.deleteSubStudyPlan}" onclick="cdDialog.hide();" update=":studyPlanEditForm"/&gt; &lt;p:commandButton value="No" onclick="cdDialog.hide();" type="button"/&gt; &lt;/p:panel&gt; &lt;/p:dialog&gt; </code></pre> <p>So the managed bean has an attribute called <code>selectedRow</code> and at the time method deleteSubStudyPlan is invoked, this attribute contains the entity that belongs to the selected row in the table.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload