2 Replies Latest reply on May 27, 2011 11:13 AM by David Wagner

    rich:select events

    David Wagner Newbie

      I'm trying to use rich:select selection to trigger an ajax event to update other fields. However, using event="change" doesn't actually perform the ajax action until focus changes away from the select.  I need the action to trigger immediately on the list click.

      An earlier post mentioned this problem, but I don't recall seeing a clear answer.

      The response to the previous question mentioned using onlistclick, but that's not an event name you can use in the a4j:ajax handler. Is there a way to invoke the ajax update from a javascript event handler?



        • 1. rich:select events
          David Wagner Newbie

          By the way, I tried this:


          <rich:select id="c_cat" value="#{manageCategories.selectedId}" onlistclick="triggerUpdate()">

                   <f:selectItems ... />


            <a4j:jsFunction name="triggerUpdate" execute="c_cat" render="cprops" oncomplete="enableDel()"  />


          This does seem to call the triggerUpdate function -- I can tell because the enableDel() function gets called -- but it doesn't do the execute or render the element named in "cprops". When I had it as an a4j:ajax handler inside the select that worked, just not immediately.


          Actually, it seems that if I select the same item a second time, then it does do the execute and render, but using the value that was selected the previous time.  Strange...

          • 2. Re: rich:select events
            David Wagner Newbie

            Perhaps this was obvious to everybody else, but here's the solution that worked for me:


            <h:selectOneListbox id="myid"  value="#{bean.value}" >     

                          <f:selectItems value="#{bean.options}" />

                          <a4j:ajax event="click" render="whatever" execute="myid" />



            Maybe you could also do this with rich:select, but this is simpler.