I'm trying to create an autocomplete input text field that sets an id or an employee Object when the form is submitted, instead of just obtaining the string from the input field. Can someone help me figure out how to achieve this? Maybe using a hidden input field or a JavaScript/ajax function. THANKS!
<rich:autocomplete mode="cachedAjax" tokens="," minChars="0"
autoFill="true" selectFirst="true"
autocompleteMethod="#{employeeBean.employeeSuggestions}" var="employee"
fetchValue="#{employee.firstName} #{employee.lastName}">
<h:inputHidden id="employeeId" value="#{employee.id}"/>
<h:column>
<h:outputText value="#{employee.firstName}" />
<h:outputText value=" " />
</h:column>
<h:column>
<h:outputText value="#{employee.lastName}" />
</h:column>
</rich:autocomplete>
</h:panelGrid>
<h:panelGrid columns="3" cellspacing="5">
<h:commandButton value="#{messages.ok}"
action="#{departmentBean.addOrUpdateDepartment}">
</h:commandButton>
<h:commandButton action="department" value="#{messages.close}"
immediate="true" />
</h:panelGrid>
Any suggestions would be appreciated.