Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>A <code>preRender</code> listener is always invoked on pre render event, regardless of if it's an initial request or a postback request. Every single request has a render response phase, regardless of if it's a normal request or ajax request. So this behaviour is by specification. You need to check yourself in the listener method if it's a postback request or not by checking <a href="http://docs.oracle.com/javaee/6/api/javax/faces/context/FacesContext.html#isPostback%28%29" rel="nofollow"><code>FacesContext#isPostback()</code></a>.</p> <pre><code>public void sendComment() { if (!FacesContext.getCurrentInstance().isPostback()) { // ... } } </code></pre> <p>The <code>&lt;f:event type="preRenderXxx"&gt;</code> (where <code>Xxx</code> can be <code>View</code> or <code>Component</code>) is by the way in essence a "workaround approach" for the functional requirement of being able to invoke a bean action method after the view parameters are been processed on the initial request. In the upcoming JSF 2.2 a new <code>&lt;f:viewAction&gt;</code> tag will be introduced which should do exactly the job as intented:</p> <pre><code>&lt;f:viewAction action="#{newsBean.sendComment}" /&gt; </code></pre> <p>This tag supports an <code>onPostback</code> attribute which already defaults to <code>false</code>:</p> <pre><code>&lt;f:viewAction action="#{newsBean.sendComment}" onPostback="false" /&gt; </code></pre> <p>JSF 2.2 will be released the first quart of 2012. Snapshot releases of JSF 2.2 are currently already available.</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