Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you're using <code>@ViewScoped</code> bean you could do the following changes:</p> <p>First change your <code>selectOpt1</code> method to type <code>void</code>:</p> <pre><code>public void selectOpt1() { this.list1Val = 1; this.list2Val = 1; //... } </code></pre> <p>Give an <code>id</code> to the component you want to update upon selecting items. I assume List 1 in this case:</p> <pre><code>&lt;h:selectOneMenu id="list1" value="#{MyClass.list1Val}"&gt; //... &lt;/h:selectOneMenu&gt; </code></pre> <p>And in your button, add an <code>f:ajax</code> tag that partially submits only that component for processing:</p> <pre><code>&lt;h:commandButton value="Select all opt1" action="#{MyClass.selectOpt1}"&gt; &lt;f:ajax execute="@this" render="list1" /&gt; &lt;/h:commandButton&gt; </code></pre> <p>If you plan to update multiple components, you may add their id separated by space:</p> <pre><code>&lt;f:ajax execute="@this" render="list1 list2" /&gt; </code></pre> <p>I hope it helps.</p> <p><strong>Edit</strong></p> <p>Well, sorry, I didn't noticed you're using JSF 1.x. In this case it wouldn't work.</p> <p>You could use a library such as <a href="http://www.jboss.org/richfaces" rel="nofollow noreferrer">RichFaces</a> to add ajax functionality though. Please, check out these topics:</p> <ul> <li><p><a href="https://stackoverflow.com/questions/12715731/ajax-behaviour-in-jsf-1-2">ajax behaviour in jsf 1.2</a></p></li> <li><p><a href="https://stackoverflow.com/questions/3545539/how-do-i-call-a-jsf-action-method-in-jsf-1-2-using-ajax">how do i call a jsf action method (in JSF 1.2) using Ajax?</a></p></li> </ul> <p><strong>RichFaces</strong></p> <p>As you mentioned you're using RichFaces you could switch the <code>f:ajax</code> tag to <code>a4j:support</code>:</p> <pre><code>&lt;h:commandButton value="Select all opt1" action="#{MyClass.selectOpt1}"&gt; &lt;a4j:support event="onclick" reRender=":list1" ajaxSingle="true" /&gt; &lt;/h:commandButton&gt; </code></pre> <p>Or like this using the <code>a4j:commandButton</code>:</p> <pre><code>&lt;a4j:commandButton value="Select all opt1" reRender=":list1" ajaxSingle="true" /&gt; </code></pre> <p>For more info on this behavior, please take a look at <a href="http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html/ArchitectureOverview.html#d0e1166" rel="nofollow noreferrer">this</a>.</p> <p>Regards.</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. 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