Jsf RichFaces autocomplete : get the String for autocomplete- method()
Posted
by
JavaNullPointer
on Stack Overflow
See other posts from Stack Overflow
or by JavaNullPointer
Published on 2012-12-14T23:02:09Z
Indexed on
2012/12/14
23:03 UTC
Read the original article
Hit count: 545
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....
© Stack Overflow or respective owner