Note that there are some explanatory texts on larger screens.

plurals
  1. POJSF commandButton with immediate="true"
    text
    copied!<p>I have a situation where there is a selectOneMenu that has a value bound to a backing bean.</p> <p>I need to have a button that doesn't update model values (that is why it has immediate="true" property).</p> <p>That button's action method changes the value the selectOneMenu is bound to, but when the page is redisplayed the original value is displayed (the one that was submitted) and not the one set in the action method.</p> <p>Any ideas why that is happening?</p> <p>If I didn't explain the problem good enough please let me know.</p> <p><hr/> EDIT: As requested here is the source code in question: <br/></p> <h3>page code:</h3> <pre><code>&lt;h:selectOneMenu id="selectedPerson" binding="#{bindings.selectPersonComponent}" value="#{bean.selectedPerson}"&gt; &lt;s:selectItems var="op" value="#{bean.allPersons}" label="#{op.osoba.ime} #{op.osoba.prezime}" noSelectionLabel="#{messages.selectAPerson}"&gt; &lt;/s:selectItems&gt; &lt;f:converter converterId="unmanagedEntityConverter" /&gt; &lt;/h:selectOneMenu&gt; ... &lt;a4j:commandButton action="#{bean.createNew}" value="#{messages.createNew}" immediate="true" reRender="panelImovine"&gt; &lt;/a4j:commandButton&gt; </code></pre> <h3>java code:</h3> <pre><code>private Person selectedPerson; public String createNew() { log.debug("New created..."); selectedPerson = null; bindings.getSelectPersonComponent().setSubmittedValue(null); //SOLUTION return ""; } </code></pre> <p>The solution is in the lined marked <b>SOLUTION</b> :)</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