4 Replies Latest reply on Jun 8, 2007 8:08 AM by Amol Somani

    How to get selected row in suggestionBox component

    Madhav Bhargava Newbie

      Hi All,

      I am using suggestionBox component in my application which then populates a h:inputText component with the value selected.

      Each row is an object of type Data. This Data object contains an ID and a text. The text value is displayed in the datatable that gets generated and shown in the popup DIV section which gets populated using Ajax request.

      The text value is then populated in the input text component using fetchValue attribute. The problem is that in the backing bean i will want the ID as the ID is actually the database identifier for the value and will then be used in creation of query.

      How do i get a selected row in the backing bean so that i can then extract the ID from the same.

      Following is the code:

      <h:inputText value="#{suggestionBox.property}" id="text" />
      
      <rich:suggestionbox id="suggestionBoxId" for="text" tokens=""
       rules="#{suggestionBox.rules}"
       suggestionAction="#{suggestionBox.autocomplete}" var="result"
       fetchValue="#{result.text}" rows="#{suggestionBox.intRows}"
       first="#{suggestionBox.intFirst}"
       minChars="#{suggestionBox.minchars}"
       shadowOpacity="#{suggestionBox.shadowOpacity}"
       border="#{suggestionBox.border}" width="#{suggestionBox.width}"
       height="#{suggestionBox.height}"
       shadowDepth="#{suggestionBox.shadowDepth}"
       cellpadding="#{suggestionBox.cellpadding}" oncomplete="">
       <h:column>
       <h:outputText value="#{result.text}" />
       </h:column>
      </rich:suggestionbox>
      


      This essentially the same code which is there in the examples in the demo

      Any help will be greatly appreciated.

      Thanks,
      Madhav