Note that there are some explanatory texts on larger screens.

plurals
  1. PO<p:dialog> rendered property not getting updated using <p:commandLink update=":dialog">
    text
    copied!<p>I have a <code>&lt;h:dataTable&gt;</code> which has a <code>&lt;p:commandLink&gt;</code> within it. I need to fetch some data from the database when <code>&lt;p:commandLink&gt;</code> is clicked and display it within a pop-up for which I am using a <code>&lt;p:dialog&gt;</code>.</p> <pre><code>&lt;h:form id="form"&gt; &lt;h:dataTable width="80%" value="#{controller.items}" var="a" binding="#{bean.table}" rendered="#{not empty controller.items}"&gt; &lt;h:column&gt; &lt;h:outputText value="#{a.date}" /&gt; &lt;/h:column&gt; &lt;h:column&gt; &lt;h:outputText value="#{a.name}" /&gt; &lt;/h:column&gt; &lt;h:column&gt; &lt;p:commandLink value="View" action="#{controller.getData()}" update=":form:dialog" oncomplete="w_dialog.show();return false;"&gt; &lt;/p:commandLink&gt; &lt;/h:column&gt; &lt;/h:dataTable&gt; &lt;p:dialog header="Test" widgetVar="w_dialog" width="600px" height="500px" id="dialog" modal="true" draggable="true" appendToBody="true" rendered="#{sessionScope.sample ne null}"&gt; &lt;ui:include src="sample.xhtml"/&gt; &lt;/p:dialog&gt; &lt;/h:form&gt; </code></pre> <p>I need to capture the data of the row which is clicked and get data from the database. My bean and controller classes are as follows:</p> <pre><code>@Named @SessionScoped public class Bean implements Serializable { private HtmlDataTable table; // getters and setters } @Named @SessionScoped public class Controller implements Serializable { @Inject private Bean bean; public void getData(){ bean.getTable().getRowData(); SampleClass sample=new SampleClass(); // fetches data from database and populates it within sample instance FacesContext context = FacesContext.getCurrentInstance(); context.getExternalContext().getSessionMap() .put("sample", sample); } } </code></pre> <p>The <code>&lt;p:dialog&gt;</code> includes a file called <code>sample.xhtml</code> which has references to <code>SampleClass</code>. So I used <code>rendered</code> property in <code>&lt;p:dialog&gt;</code> to avoid <code>NullPointer Exception</code> on loading my xhtml page.Also, <code>sample</code> of type <code>SampleClass</code> is inserted into the sessionMap only after the controller method <code>getData()</code> is executed on clicking the <code>&lt;p:commandLink&gt;</code>. </p> <p>The problem is that the pop-up never gets displayed even after the method <code>getData()</code> is executed and <code>sample</code> is inserted into the SessionMap.</p> <p>I have used <code>update=:form:dialog</code> to update the dialog after the <code>&lt;p:commandLink&gt;</code> is clicked. But it seems that the <code>rendered</code> property of the dialog never gets updated. So i cannot see the <code>&lt;p:dialog&gt;</code>.</p> <p>Am I missing something?</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