Hi,
I need to bind to an inputText an object.
I retrieve with suggetionBox a city, and I need to persist the primary key of it.
That's the code for suggestionBox:
<h:inputText value="#{laboratoryHome.instance.city}" id="cityId" /> <rich:suggestionbox id="citySuggestionBoxId" for="cityId" tokens="," rules="#{citySuggestionBox.rules}" suggestionAction="#{citySuggestionBox.autocomplete}" var="city" fetchValue="#{city}" first="#{citySuggestionBox.intFirst}" minChars="2" usingSuggestObjects="#{citySuggestionBox.usingSuggestObjects}">
public List autocomplete(Object suggest) { String pref = (String)suggest; ArrayList<City> result = new ArrayList<City>(); Iterator<City> iterator = getAllData().iterator(); while (iterator.hasNext()) { City elem = iterator.next(); if ((elem != null && elem.getName().toLowerCase().indexOf(pref.toLowerCase()) == 0) || "".equals(pref)) { result.add(elem); } } return result; }