3 Replies Latest reply on Jun 10, 2010 8:43 AM by ibstmt

    SuggestionBox problem

    ibstmt Newbie

      I've done a lot of Web research to get the following to work, but it's just not working. I have a SuggestionBox on my form. It retrieves the suggested values perfectly. It shows the list. It populates the box with my fetch value. The problem is that I simply cannot get the selection event to fire no matter what I do. Nothing happens. No error messages. The only way I see anything is when I click the command button to process my form.

      One other clue: if I do a search on 123, select something, and then do another search on 5678, I get a ConcurrentModificationException. When I debug, the breakpoint on the second search is actually searching for 123 again, and then the next breakpoint on that method is for the 5678 search. Can't figure out why the second search is triggering two searches on two different strings.

      <h:outputText value="Model Search: " />
      <h:inputText id="mod"/>     
         <rich:suggestionbox width="500" for="mod" var="result" fetchValue="#{result.fullDescription}" minChars="3"     immediate="true"
                   <h:outputText value="#{result.fullDescription}" />
            <a4j:support event="onselect" eventsQueue="q1" immediate="true">
                      <f:setPropertyActionListener value="#{result}" target="#{siteManager.searchModel}" /> 

        • 1. Re: SuggestionBox problem
          Andrew Wheeler Newbie

          First off your inputText does not have a value property. However I tend to skip the action listener. I use seam's extended el (actions with parameters) with an Ajax call to your backing bean.

            <a4j:support event="onselect" ajaxSingle="true" bypassUpdates="true" action="#{siteManager.setSearchResult(result.id)}"/>

          You can pass any value you want. In my case I don't want the text value of the search result but the underlying id of the search entity such as a person or company. You can then re-render any ajax enabled area or component on your page using reRender if required. The ajaxSingle and bypassUpdates means no other values will be submitted and validation will not take place.

          • 2. Re: SuggestionBox problem
            ibstmt Newbie

            Thanks, but that doesn't work. I have tried three or four techniques for this, but the Ajax event simply refuses to fire for the suggestion box, no matter what. There's a h:selectOneMenu component right above it which also uses a4j:support to fire an action, and that works fine. It's just the rich:suggestionbox that won't do it.

            I might add that my page is a .xhtml page. I am wondering if there is some issue related to that.

            • 3. Re: SuggestionBox problem
              ibstmt Newbie

              Also note that I've got a command button at the bottom of my form:

              <a4j:commandButton value="Add" reRender="resultsPanel" action="#{myAction}"/>

              When I click that, then the action specified in the suggestionbox Ajax event fires.