2 Replies Latest reply on Jul 14, 2009 7:39 AM by francof

    Suggestionbox question

      Hi

      How do I call a server function in the onobjectchange event ?

      What i want to do that if the user starts a new search by typing in a new value in the text box, my backing bean should set the property as null.
      I tried using the onobjectchange event, but looks it takes only Javascript and I want to call some server code and use it like this -
      onobjectchange="#{selectProductKey.setItem(null)}"



      My code if it helps understand better.

      <h:inputText id="itemCode"
       size="20"
       maxlength="30"
       label="Item code"
       autocomplete="off"
       value="#{selectProductKey.itemCode}" >
      </h:inputText>
      <rich:suggestionbox
       for="itemCode"
       var="resultItem"
       width="600"
       minChars="2"
       shadowDepth="4"
       shadowOpacity="4"
       cellpadding="2"
       ajaxSingle="true"
       suggestionAction="#{selectProductKey.suggestItem}"
       usingSuggestObjects="true"
       fetchValue="#{resultItem.itemCode}"
       nothingLabel="No items found" >
      
       <h:column> <h:outputText value="#{resultItem.itemCode}" /> </h:column>
       <h:column> <h:outputText value="#{resultItem.modelName}" /> </h:column>
       <h:column> <h:outputText value="#{resultItem.modelDescription}" /> </h:column>
      
       <a4j:support event="onselect" action="#{selectProductKey.selectItem(resultItem)}"
       reRender="itemDescription"/> <!-- reRender="itemDescription,chooseProductClassPanel" -->
      </rich:suggestionbox>
      



      Basically, I am looking for a "onunselect" action - the user backspaces or changes value in the text box. The onobjectchange is the event here I believe but I'm not sure how to call a server function.

      thanks
      Franco


        • 1. Re: Suggestionbox question
          ilya_shaikovsky

          you could use a4j:support to trigger request. but onobject change is not similar to onunselect.

          • 2. Re: Suggestionbox question

            Thank you Ilya

            Pardon me, I did not understand when you say "to trigger request"

            In the demo example, you use the onclick with a call to callSuggestion(true) - how would that help here?


            Do I put a a4j:support event on the suggestionbox control or the inputText ?
            Use onkeyup event?


            thanks again
            Franco