Jsf RichFaces autocomplete : get the String for autocomplete- method()
- by JavaNullPointer
Part of my xhmtl-Page:
<rich:autocomplete autocompleteMethod="#{autocompletMit.searchbyName()}" mode="cachedAjax"
fetchValue="#{controller.mitarbeiter.mitarbeiterName}" autocompleteList="#{autocompletMit.autocompleteList}" minChars="1" autofill="true" var="it" >
<h:outputText value="#{it.mitarbeiterName}" style="font-weight:bold"/>
</rich:autocomplete>
Bean for my Autocomplete:
@ManagedBean(name = "autocompletMit")
@RequestScoped
public class AutoCompleteMitarbeiter implements Serializable {
@EJB
private Transaktionssteuerung transakt;
private List<String> autocompleteList = new ArrayList<String>();
String nameSearch;
public List<String> searchbyName(Object o) {
String test = (String) o; //always get here a NullPointerException
List<Mitarbeiter> alleMitarbeiter = transakt.alleMitarbeiter();
for (Iterator<Mitarbeiter> it = alleMitarbeiter.iterator(); it.hasNext();) {
if (it.next().getMitarbeiterName().startsWith(test)) {
autocompleteList.add(it.next().getMitarbeiterName());
}
}
return autocompleteList;
}
I always get a NullPointerException for String test = (String) o; I dont know how to get the StringInput correctly from </rich:autocomplete>-Input....