Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If I understand correctly, there are some validations elsewhere in the form that are failing. When any of the submitted form values fail validation then none of the submitted values are applied to the managed bean unless <code>immediate</code> is used. This is why it seems that you are able to add a new row but not with the <code>doStuff</code> method. You did not add <code>immediate</code> to <code>doStuff</code>.</p> <p>But stating that there are a few things you could do much more cleanly and efficiently.</p> <p>First, the <code>action</code> attribute should really be used for navigation actions. JSF expects that methods bound to an <code>action</code> have a return value that represents the navigation result. For <code>void</code> methods it is better to use <code>actionListener</code>. For more information on the difference between <code>action</code> and <code>actionListener</code> read here: <a href="https://stackoverflow.com/questions/3909267/differences-between-action-and-actionlistener">Differences between action and actionListener</a></p> <p>Secondly, why not just set <code>process</code> and <code>update</code> to only the data table component and then you don't have to worry about other form validations? Here is an example:</p> <pre><code>&lt;h:form id="my-form"&gt; &lt;p:dataTable value="#{testBean.list}" var="s" id="datatable"&gt; &lt;p:column&gt; &lt;h:inputText value="#{s}"/&gt; &lt;/p:column&gt; &lt;f:facet name="footer"&gt; &lt;p:commandButton value="Add row" actionListener="#{testBean.addRow}" process=":my-form:datatable" update=":my-form:datatable" /&gt; &lt;p:commandButton value="Do stuff" actionListener="#{testBean.doSomeLogic}" process=":my-form:datatable" update=":my-form:datatable" /&gt; &lt;/f:facet&gt; &lt;/p:dataTable&gt; &lt;/h:form&gt; </code></pre>
 

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