6 Replies Latest reply on Apr 13, 2007 6:38 AM by greko

    suggestionbox - feature request and question

    greko

      Hi !

      About suggestionbox, I want to find a way to fetch a value (witch is not my input fetched value) into a <h:outputText> when i select a value.

      I can perform this by doing a <a4j:support event="onselect" , with an actionlistener and a reRender instruction.
      ...but is there an easier way to do it ?

      Then, my feature request : i'd love to customize my suggestion list, so that i can bold the part of the result string corresponding to the searchstring (the one im typing). You can see it in action at mappy.com (or maps.google.com).


      Thank you, guys !

        • 1. Re: suggestionbox - feature request and question

          if you want to update the value printed by the h:outputText, you do it right way. In theory, you can change something on the client side using <a4j:support onsubmit="...">. However, if you replace the outcome h:outputText, it will be out-of-sync with the server side value of it.

          suggestion box works like dataTable. So, you can highlight what ever you want there in the manner you can do it in the regular dataTable outcome.

          • 2. Re: suggestionbox - feature request and question
            greko

            Thanks for your reply,

            But i don't think it really answers my question.


            Here is my sample code :

            <h:inputText value="#{settings.currentPrincipal}" id="suggest" />
            <!-- fetch #{suggest.value2} here -->
            <span id="val2"></span>
            
            <rich:suggestionbox for="suggest"
             suggestionAction="#{pageBean.autocomplete}"
             eventsQueue="myQueue"
             fetchValue="#{suggest.value1}"
             requestDelay="500" ignoreDupResponses="true"
             width="200" height="100"
             onselect="alert('#{suggest.value2}');"
             var="suggest">
             <h:column>
             <h:outputText value="#{suggest.value1}"/>
             </h:column>
             <h:column>
             <h:outputText value="#{suggest.value2}"/>
             </h:column>
            </rich:suggestionbox>
            
            


            I want to find a way to fetch #{suggest.value2} somewhere (a span for example), but i can't access my suggest var in javascript (onselect or oncomplete). It is not possible with <a4j:support> either...





            • 3. Re: suggestionbox - feature request and question
              ilya_shaikovsky

              yes you need to use support for onselect in your case I think.

              • 4. Re: suggestionbox - feature request and question
                greko

                Unfortunatelly, <a4j:support> can't catch my suggest variable ...

                I tried something like this :

                ...
                <a4j:support event="onselect" actionListener="#{pageBean.select(suggest.value2)}" reRender="some_id" />
                ...
                


                But the parameter (suggest.value2) is empty... as if my suggest variable were unreacheable.

                • 5. Re: suggestionbox - feature request and question
                  ilya_shaikovsky

                  but after you add this support your input will be submited also. So you may get #{settings.currentPrincipal} on server and get some additional info after that.

                  • 6. Re: suggestionbox - feature request and question
                    greko

                    yes, it's true. But it costs me a db call to get extra info, whereas i already have this info through the autocomplete method ...

                    we found a solution, using only javascript, but its a bit tricky (fetch both values in the input field, then split and do what i want to do).

                    I though there could be an easier way to do this.


                    Thanks, BTW !