Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If I understood correctly you want to disable the <em>New</em> button when you click on the <em>Open</em> button.</p> <p>You don't need to put your toolbar into a form, you can disable that button through JavaScript:</p> <pre><code>&lt;p:commandButton type="button" value="New" icon="ui-icon-document" widgetVar="disablethis"/&gt; &lt;p:commandButton type="button" value="Open" actionListener="#{bean.anyMethod}" update=":frm" onclick="disablethis.disable()"/&gt; </code></pre> <p>Also try referencing your form with <code>:frm</code> in your <code>update</code>.</p> <p>You should also consider changing the <code>onclick</code> action depending on your requirements to:</p> <ul> <li><em>onstart</em></li> </ul> <p>Client side callback to execute before ajax request is begins.</p> <ul> <li><em>onclick</em></li> </ul> <p>Client side callback to execute when button is clicked.</p> <ul> <li><em>onsuccess</em></li> </ul> <p>Client side callback to execute when ajax request succeeds.</p> <ul> <li><em>oncomplete</em></li> </ul> <p>Client side callback to execute when ajax request is completed.</p> <p><strong>EDIT</strong></p> <p>If you want to solve this without explicit JavaScript you need to have a flag in your backing bean (as you already discovered), indicating is the Open button disabled or not. Then call the <code>anyMethod</code> of your backing bean (which will set that flag inside as you described) and finally update the <em>Open</em> button:</p> <pre><code>&lt;p:commandButton value="New" action="#{bean.anyMethod}" icon="ui-icon-document" update="button1"/&gt; &lt;p:commandButton id="button1" value="Open" type="button" disabled="#{bean.disabled}"/&gt; </code></pre> <p>Have the appropriate getters/setters in your backing bean, and set the flag in <code>anyMethod</code>:</p> <pre><code>private boolean disabled; public boolean isDisabled() { return disabled; } public void setDisabled(boolean disabled) { this.disabled = disabled; } public void anyMethod() { if (disabled) { disabled = false; } else { disabled = true; } } </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