4 Replies Latest reply on Oct 21, 2011 3:36 AM by pradeep_nayak

    Action method call on dropdown  value change

    pradeep_nayak

      Hi

       

       

      I'm using richfaces 4 final version.

      I need to call an action method on value change of  dropdown.

      Is there any way I can achieve this ?  In the previous versions of richfaces  a4j:ajax  had the ' action'  attribute which used to call the specified action method. But in the latest version i do not see this attribute?  Is there any replacement ?

       

      On value change I need to render a different page. As of now i'm using a value change listener and forward to another page using facesCtx api.

       

      Thanks

      Pradeep

        • 1. Re: Action method call on dropdown  value change
          iabughosh

          it can be done with a4j:jsFunction :

          <h:selectOneMenu id="select"

                                   value="#{optionTree.value}">

                      <f:selectItem itemLabel="1" itemValue="1"/>

                      <f:selectItem itemLabel="2" itemValue="2"/>           

                      <a4j:ajax event="change" execute="@this" oncomplete="navigate()"/>

                  </h:selectOneMenu>

                  <a4j:jsFunction name="navigate" action="yourNavigation rule"/>

          • 2. Re: Action method call on dropdown  value change
            pradeep_nayak

            Thanks a lot Ibrahim.

             

             

            It worked for me. but i have another problem.  I have used your solution in a page. Same page has  a4j:poll.    When the poll is happening if I select the drop down its not calling the action method configured in a4j:jsfunction.  But when the poll stops or poll is disabled  it works. Does a4j:poll block other a4j requests. ( They are in diffferent forms). Do I have to use @execute in poll ? or Do ihave to use a4j:region ?

            • 3. Re: Action method call on dropdown  value change
              iabughosh

              honestly i didn't try this, could you please check @execute, a4j:region and reply back.

              • 4. Re: Action method call on dropdown  value change
                pradeep_nayak

                I tried  execute=''@none"  it worked.

                 

                But there was a side effect. I had a pie chart displayed on page using a javascript on window load. That stopped displaying