8 Replies Latest reply on Mar 26, 2010 7:04 AM by ibrewster

    suggestionbox with actionparam

      I am trying to make a suggestionbox pass multiple parameters to the server and i have been unsuccessful even though i believe that I am using the correct approach based on the following resources:

       

      http://www.jboss.org/file-access/default/members/jbossrichfaces/freezone/docs/devguide/en/faq/faq.html

       

      http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4063764

       

      I can get the functionality it to work by hard coding a value in the actionparam but the EL value (see code below) doesn't work because it passes an empty value to the server even though i know the value exists.  Could this have something to do with the type of list being used in the suggestionbox?  I have been working on this for a few days now and any help would really be appreciated.

       

      My xhtml code:

      ...
      <h:inputText id="originCity" value=""/>
      
      <rich:suggestionbox id="origSuggestion" 
           for="originCity" 
           var="_origin" 
           fetchValue="#{_origin.city}" 
           suggestionAction="#{geoCityHome.autosuggest}" 
           minChars="1">
      
      <h:column>
           <h:outputText id="origSuggestCity" value="#{_origin.city}, #{_origin.countryName}" />
      </h:column>
      
      <a:support event="onselect" ajaxSingle="true" reRender="out">
           <a:actionparam name="origCountry" 
                value="#{_origin.countryName}" 
                assignTo="#{quoteManager.originCountry}" />
      </a:support>
      
      </rich:suggestionbox>
      
      <h:outputText id="out" value="#{quoteManager.originCountry}" />
      ...
      

       

      The geoCityHome.autosuggest returns List<Entity>.  Hope someone can shed some light on my problem here.  Thanks!

        • 1. Re: suggestionbox with actionparam
          ilya_shaikovsky

          if you see correct output there

               <h:outputText id="origSuggestCity" value="#{_origin.city}, #{_origin.countryName}" />

          then the next code    

               <a:actionparam name="origCountry" 
                    value="#{_origin.countryName}" 
                    assignTo="#{quoteManager.originCountry}" />

          should also works fine.. which RF used?

          • 2. Re: suggestionbox with actionparam

            I'm running on verson 3.3.1.GA.

             

            This works:

                 <h:outputText id="origSuggestCity" value="#{_origin.city}, #{_origin.countryName}" />

             

            This works:

                 <a:actionparam name="origCountry" 
                      value="United States"
                      assignTo="#{quoteManager.originCountry}" />

             

            but this doesn't work:

                 <a:actionparam name="origCountry" 
                      value="#{_origin.countryName}" 
                      assignTo="#{quoteManager.originCountry}" />
            • 3. Re: suggestionbox with actionparam
              ilya_shaikovsky
              please check with 3.3.3CR1
              • 4. Re: suggestionbox with actionparam
                I upgraded to 3.3.3.CR1 and it still returns an empty value.  Any additional thoughts?
                • 5. Re: suggestionbox with actionparam

                  Does anyone have this working or is this a bug?

                  • 6. Re: suggestionbox with actionparam
                    ilya_shaikovsky

                    I'm really sorry for pointing you to wrong direction from the beggining.

                     

                    As suggestionBox not based on repeat component for iteration data it has no feature or proper encoding the support for every row with concrete parameters for the row. So this problem really exist as actionparam not properly output to the client side in this case.

                     

                    But the good news is that simple solution exist:

                    <a4j:support event="onselect" reRender="out">
                         <f:setPropertyActionListener target="#{capitalsBean.currentStateFilterValue}" value="#{result.state}"> </f:setPropertyActionListener> 
                    </a4j:support>
                    
                    wil works just as you need.
                    • 7. Re: suggestionbox with actionparam

                      Thank you very much, this works!!  Here is the final snippit of code that worked for me.

                      <a4j:support event="onselect" reRender="out">
                           <f:setPropertyActionListener target="#{quoteManager.originCountry}" value="#{_origin.country}"> </f:setPropertyActionListener> 
                      </a4j:support>
                      

                       

                      I'm curious if there is some way to use the actionparam IF i decided to change the format of my data (possibly using the @DataModel annotaion or something?)  Is there some resource which explains how the rich:suggestionBox suggestionAction converts the List<Enity>?  I think i read that it uses JSON somehow to convert the entity into xml?  Anyway, thanks again for solving my problem.

                      • 8. Re: suggestionbox with actionparam

                        I've used this and it works fine, however I have an additional issue with form submission as described here [https://community.jboss.org/message/62086#62086]

                         

                        I basically have a suggestion box to select a country on a form that has a number of other fields, some of which are mandatory, although the country is not. On selecting a suggestion box entry and pressing enter the form is submitted which causes validation errors because of my lack of required field values. My selected suggestion box value is not saved to the bean although the value is displayed in the <h:inputText> field. I can't trap onselect because I need it for the propertyActionListener. My code is here

                         

                        {code:xml}

                                   <s:decorate id="nationalityField" template="/layout/edit.xhtml">
                                      <ui:define name="label">
                                        <h:outputText value="#{commonText.nationality}"/>
                                      </ui:define>
                                      <h:inputText id="nationality"
                                                   title="#{bookingText['maintainTraveller.nationalityTooltip']}"
                                                   value="#{travellerHome.instance.person.countryName}"
                                                   style="width:250px">
                                      </h:inputText>
                                      <rich:suggestionbox height="250" width="250"
                                                          suggestionAction="#{countryList.suggestions}"
                                                          var="_country"
                                                          for="nationality"
                                                          fetchValue="#{_country.name}"
                                                          tokens=",">
                                        <h:column>
                                          <h:outputText value="#{_country.name}"/>
                                        </h:column>
                                        <a4j:support event="onselect" for="nationality">
                                          <f:setPropertyActionListener target="#{travellerHome.instance.person.country}"
                                                                       value="#{_country}"/>
                                        </a4j:support>
                                      </rich:suggestionbox>
                                    </s:decorate>

                        {code}

                         

                        Anyone got suggestions?

                         

                        Thanks

                        Ian