Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h3>What's going on?</h3> <p>What you get is correct behaviour. In PrimeFaces button with <em>type="button"</em> works as it does in basic HTML - it doesn't cause any request. As <a href="http://primefaces.org/documentation.html" rel="noreferrer">PrimeFaces user's guide</a> says:</p> <blockquote> <p>Push buttons are used to execute custom javascript <strong>without causing an ajax/non-ajax request</strong>. To create a push button set type as "button".</p> <pre><code>&lt;p:commandButton type="button" value="Alert" onclick="alert('Prime')" /&gt; </code></pre> </blockquote> <p>If you want to "talk to" bean, you need to use <em>type="submit"</em> (which is default in p:commandButton). However... contrary to submit buttons behaviour in HTML, in PrimeFaces such submission will not force redirection to new page but all communication will be handled by underlying AJAX requests.</p> <p>Therefore only your second button will execute beans' method:</p> <pre><code>&lt;p:commandButton id="s" value="submit" action="#{andreBean.runSubmit}" /&gt; </code></pre> <h3>What probably you wanted to obtain?</h3> <p>If you don't want to send all your form to bean you can limit the scope of components that are processed with "process" attribute of p:commandButton:</p> <pre><code>&lt;h:form id="test"&gt; &lt;p:inputText value="#{andreBean.value}"/&gt; &lt;p:commandButton id="s" value="submit" action="#{andreBean.runSubmit}" process="@this" /&gt; &lt;/h:form&gt; </code></pre> <p>With the following bean you will see the difference:</p> <pre><code>public class AndreBean { private String value; public void runSubmit() { System.out.println("Submit executed"); } public String getValue() { System.out.println("getValue"); return value; } public void setValue(String value) { System.out.println("setValue: " + value); this.value = value; } } </code></pre> <p>If you don't limit executed components in console you get:</p> <pre><code>getValue setValue: foobar Submit executed </code></pre> <p>...and with components limited only to <em>process="@this"</em> you get only:</p> <pre><code>Submit executed </code></pre> <p>Hope that helps.</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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