0 Replies Latest reply on Jul 5, 2010 4:30 PM by Paul Botta

    Suggestionbox - Getting more info about selected item - How do I?

    Paul Botta Newbie

      I am using a rich:suggestionbox and I need to get more information about the selected item besides what is returned using fetchValue.

       

      Requirement: The user enters the last name of a student in the suggestion box.  When selected, the first and last names appear in the box and when the user hits save, the updated information is saved.

       

      Problem: Because first name, last name may not be unique across the student population, I need to determine the (unique) id of the student that was selected so that the updated is performed on the correctly selected student.

       

      Code:  I tried this, but the value of selectedStudentId is null:

       

      <rich:suggestionbox
                id="schSuggestionBox"
                for="schStdntSlct"

                suggestionAction="#{tuitionPlanController.autocomplete}"
                var="student"
                fetchValue="#{student.lastName}, #{student.firstName}"
                minChars="2"
                shadowOpacity="25"
                border="1"
                width="225"
                shadowDepth="8"
                cellpadding="5"
                nothingLabel="No matching students were found"
                columnClasses="center"
                usingSuggestObjects="true">
            
                <h:column>
                     <h:outputText value="#{student.firstName} #{student.lastName}" style="padding-left:10px;" styleClass="dndTextHdline"/>
               </h:column>

       

             <a4j:support event="onselect" ajaxSingle="true" immediate="true" action="#{tuitionPlanController.studentSelected}">
                 <f:param name="selectedStudentId" value="#{student.id}"/>
             </a4j:support>

       

          </rich:suggestionbox>

       

       

      Backing Bean

        
          public void studentSelected() {
              String selectedStudentId = FacesUtils.getRequestParameter("selectedStudentId");
              System.out.println("selectedStudentId="+selectedStudentId);
          }

       

       

       

      If I hardcode a value as in:

       

      <f:param name="selectedStudentId"  value="999"/>

       

      it works.

       

       

      Any suggestions?  Thanks.