Note that there are some explanatory texts on larger screens.

plurals
  1. POBinding process occurs before action is taken in JSF 2
    primarykey
    data
    text
    <p>I'm using PrimeFaces with JSF 2.0, I have this layout:</p> <pre><code>&lt;h:panelGroup layout="block" id="panelGroup" binding="#{bean.boundPg}" /&gt; &lt;p:commandButton value="Update" action="#{bean.updateMe}" update="panelGroup" /&gt; </code></pre> <p>in which, the bean is <code>SessionBean</code>. By using log4j to debug I found out that the binding process called <code>getBoundPg</code> before executing the action <code>updateMe</code>. So the view is always out-of-date.</p> <p>Do you know why and how to reverse that order? Thanks!</p> <p>------------- Edit ---------------</p> <p>I'm making a web app for a quiz game.</p> <pre><code>&lt;h:panelGroup layout="block" id="pgContents" binding="#{bean.boundContents}" /&gt; &lt;p:commandButton value="Prev page" action="#{bean.prevPage}" update="pgContents" /&gt; &lt;p:commandButton value="Next page" action="#{bean.nextPage}" update="pgContents" /&gt; </code></pre> <p><code>pgContents</code> contains many <code>h:pannelGroup</code>s, each sub-group contains a label showing the content of a quiz, a <code>h:inputText</code> for the player to give their answer. Because of some reasons, I had to generate the children of <code>pgContents</code> programmatically.</p> <p>The <code>Prev page</code> and <code>Next page</code> buttons will retrieve the prev/next group of quiz</p> <p>Below is the bean (getters &amp; setters are skipped)</p> <pre><code>@ManagedBean(name = "bean") @SessionScoped public class LessonHelper { private int currentPage; private HtmlPanelGroup boundContents; public void prevPage() { // decrease currentPage // fetch contents // add children for boundContents (label, inputText) } // nextPage() is similar } </code></pre> <p>My problem is that, when I click the Prev/Next button, the getter <code>getBoundContents</code> is called first in binding process, and the <code>prevPage()/nextPage()</code> is called later, which cause the content always out-of-date.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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