7 Replies Latest reply on May 16, 2007 12:37 PM by gernotr

    rerender selectonemenu on suggestionbox selection/change

    shooali

      hi,

      I am posting this in continuous to a previous post of mine (http://jboss.com/index.html?module=bb&op=viewtopic&t=105109&postdays=0&postorder=asc&start=10)

      I have seen that it was changed in the 3.0.1 version that suggestionbox no longer works in ajaxsingle mode (true) only, so I have added ajaxSingle=false to the suggestionbox tag, but still I am getting a null value on the inputText property (that is bound to the suggestionbox) when the selectonemenu element is rerendered.

      I have tried many way (a4j:support on the suggestionbox, a4j:support on the inputText, onselect att in the suggestion box that triggers a fake event on another element on the page , inside the same form tag, that has a4j:support to reRender the selectonemenu...) nothing works ok.

      how can I make the selectonemenu to reRender on value changed event in another inputText element on the page, and that inputText is "bound" to a suggestionbox.

      Thanks in advance,



        • 1. Re: rerender selectonemenu on suggestionbox selection/change
          ilya_shaikovsky

          Describe please step by step your scenario.

          • 2. Re: rerender selectonemenu on suggestionbox selection/change
            shooali


            I will try to give a common example of a need for such behavior:

            suppose you want to give a user the option to choose a country and a city. The country he can type manually, and have a suggestions list opened for him when he type characters. this is implemented with suggestionbox. Then, for each time he chooses a country, either by typing himself or by selecting from the list suggested, he will have the cities list updated according to the selected country, thus the cities list is implemented with the selectonemenu element.

            how can I have the cities element, get updated according to the selected country above?

            thanks,

            • 3. Re: rerender selectonemenu on suggestionbox selection/change

              I did not see h:messages on your latest snippet. If you add:

              <a4j:outputPanel ajaxRendered="ajax">
               <h:messages />
              </a4j:outputPanel>


              somewhere on the page, does it show something particular ?

              • 4. Re: rerender selectonemenu on suggestionbox selection/change
                shooali


                I have added that, nothing is shown. there is no exception or error.

                Is there a way to implement the simple country city scenario I have described?

                1. if I add a reRender in the suggestionbox for the selectOneMenu, in the getCitiesPerCountry method in the page bean, when I call the getCountry getter of the country property, I get null, since it's setter was called with null just before that....

                2. adding reRender to the inputText just cause more problem, I guess it conflicts with the suggestionbox "listening" to it also.

                plz help

                here is a sample code:

                
                <h:inputText id="country" value="#{pageBean.country}"/>
                <rich:suggestionbox id="countrySuggestions" for="country" suggestionAction="#{pageBean.countrySuggestions}" var="suggestedCountry">
                 <h:column>
                 <h:outputText value="#{suggestedCountry}"/>
                 </h:colums>
                </rich:suggestionbox>
                
                <h:selectOneMenu id="city" value="#{pageBean.city}">
                 <f:selectItems value="#{pageBean.citiesPerCountry}"/>
                </h:selectOneMenu>
                
                


                • 5. Re: rerender selectonemenu on suggestionbox selection/change

                  surround inputText and rich:suggestionbox with one < a4j:region />, then repeat your #1

                  What should happen if user does not use suggestion box, but types the country manually?
                  a) she types the non-existing country and leaves the field
                  b) she types the existing country and leaves the field

                  Those scenarios are not clean for me (based on the provided code snippet)

                  • 6. Re: rerender selectonemenu on suggestionbox selection/change
                    shooali

                    I did try putting the whole page under one a4j:region, it does not help, when the 'selectItems' method is called, it call the inputText getter and gets null.

                    previously you have posted that suggestion box works always in single mode. but I understand it was changed. I have added ajaxSingle=false to it, but it did not change any thing.

                    is there a way to implement this simple country city scenario with richfaces suggestion box? the only problem is with it. if u put an a4j:support on another element on the page, just for testing, it works fine.

                    as for you a+b remarks, you are right. I need to work in these scenarios also.

                    thanks.

                    • 7. Re: rerender selectonemenu on suggestionbox selection/change
                      gernotr

                      hi!

                      i've had similar problems.
                      i solved it (for me) with the following:

                      input and suggestion are in the same region
                      the onselect of the suggestion calls a js function on oncomplete
                      this function uses seam remote to explicit set the input value in the bean.

                      so in the suggestionAction of my next suggestionbox i have the value from the first input

                      maybe this helps.