5 Replies Latest reply on Jun 26, 2009 7:23 PM by Stefano C

    Combobox & onselect / onchange action

    Pieter Bosman Newbie

      Hello all,

      First of all, thanks for reading!

      I'll go straight into the issue.
      The basic question is how do I get my webapplication to call a method in my backingbean whenever my selection changes in my combobox. Sounds easy enough, but I've been getting head-aches for days now :(

      Anyways, here's the code-snippet for my jsp page.

      ...
      <rich:tab label="Skills">
       <h:panelGrid columns="2">
       <h:form>
       <h:panelGrid columns="2" id="addSkill">
       <h:outputText value="Selecteer Vaardigheid: " />
       <rich:comboBox directInputSuggestions="true" id="addSkillList"
       defaultLabel="Selecteer Vaardigheid..."
       value="#{sessionManager.toBeAddedVaardigheid}" required="true"
       width="250" onchange="#{sessionManager.toBeAddedVaardigheid}">
       <f:selectItems
       value="#{sessionManager.availableVaardighedenTable}" />
       </rich:comboBox>
       <h:outputText value="Kostprijs:" />
       <h:inputText value="#{sessionManager.teBetalenEp}"
       required="true" />
       </h:panelGrid>
       <h:outputText value=" " />
       <a4j:commandButton value="Add" id="addSkillButton"
       reRender="personageSelectionGrid, globalPanel, actionPanel, editPanel, deletePanel, loggingPanel"
       action="#{sessionManager.addSelectedVaardigheid}" />
       </h:form>
       </h:panelGrid>
       <h:panelGrid columns="1" border="1" cellspacing="5" cellpadding="2">
       <rich:messages style="color:red;"></rich:messages>
       </h:panelGrid>
      </rich:tab>
      ...
      


      The weird thing is that when I press my 'add'-button the setter method for the value linked to the combobox is fired.
      However I wish for some way to fire 'a' method whenever the selection changes

      any and all replies are appreciated!

      regards,
      Pieter

        • 1. Re: Combobox & onselect / onchange action
          Ilya Shaikovsky Master

          onchange - is a client side event handler and you seems just need a4j:support.

          check basic samples.

          • 2. Re: Combobox & onselect / onchange action
            Pieter Bosman Newbie

             

            "ilya_shaikovsky" wrote:
            onchange - is a client side event handler and you seems just need a4j:support.

            check basic samples.


            Hey Ilya,

            thanks for really fast response! Much appreciated!
            Haven't checked the 'basic examples' you mentioned to be honest (you do mean anything I find using google I hope)

            But I did try to add the <a4j:support ... /> thingie though:

            ...
            <rich:comboBox directInputSuggestions="true" id="addSkillList"
             defaultLabel="Selecteer Vaardigheid..."
             value="#{sessionManager.toBeAddedVaardigheid}" required="true"
             width="250" onchange="#{sessionManager.toBeAddedVaardigheid}">
             <a4j:support action="onchange" ajaxSingle="true"/>
             <f:selectItems
             value="#{sessionManager.availableVaardighedenTable}" />
            </rich:comboBox>
            ...
            


            Yet this doesn't resolve anything.

            Care to elaborate please?

            Thanks in advance!

            regards,
            Pieter

            • 3. Re: Combobox & onselect / onchange action
              Stefano C Newbie

              Hi,
              i think you have to replace:
              <a4j:support action="onchange" ajaxSingle="true"/>
              with
              <a4j:support event="onselect" ajaxSingle="true"/>

              Sure you can find usefull this page:
              http://livedemo.exadel.com/richfaces-demo/richfaces/support.jsf?tab=selects&cid=818128

              "pbosman" wrote:
              "ilya_shaikovsky" wrote:
              onchange - is a client side event handler and you seems just need a4j:support.

              check basic samples.


              Hey Ilya,

              thanks for really fast response! Much appreciated!
              Haven't checked the 'basic examples' you mentioned to be honest (you do mean anything I find using google I hope)

              But I did try to add the <a4j:support ... /> thingie though:

              ...
              <rich:comboBox directInputSuggestions="true" id="addSkillList"
               defaultLabel="Selecteer Vaardigheid..."
               value="#{sessionManager.toBeAddedVaardigheid}" required="true"
               width="250" onchange="#{sessionManager.toBeAddedVaardigheid}">
               <a4j:support action="onchange" ajaxSingle="true"/>
               <f:selectItems
               value="#{sessionManager.availableVaardighedenTable}" />
              </rich:comboBox>
              ...
              


              Yet this doesn't resolve anything.

              Care to elaborate please?

              Thanks in advance!

              regards,
              Pieter


              • 4. Re: Combobox & onselect / onchange action
                Pieter Bosman Newbie

                 

                "stefanorg" wrote:
                Hi,
                i think you have to replace:
                <a4j:support action="onchange" ajaxSingle="true"/>
                with
                <a4j:support event="onselect" ajaxSingle="true"/>

                Sure you can find usefull this page:
                http://livedemo.exadel.com/richfaces-demo/richfaces/support.jsf?tab=selects&cid=818128


                Gawd... 340 times I've read my code and 340 times I missed it completely... action instead of event...

                Thanks a million Stefano!

                • 5. Re: Combobox & onselect / onchange action
                  Stefano C Newbie

                  Your welcome :D

                  "pbosman" wrote:


                  Gawd... 340 times I've read my code and 340 times I missed it completely... action instead of event...

                  Thanks a million Stefano!