I am migrating from Icefaces selectInputText to Primefaces autoComplete component.
<ice:selectInputText styleClass="adminAppUserSelect"
id="searchUser" value="#{appUserData.selectedUserName }" rows="50"
width="100%" listVar="userList"
valueChangeListener="#{appUserData.updateListUser}"
binding="#{appUserData.userAutoComplete}"
title="#{msg.WEB_ADMIN_PAGES_APPUSER_AUTOCOMPLETE}"
listValue="#{appUserData.matchesListUser}">
<f:facet name="selectInputText" >
<ice:panelGrid columns="3" width="400px" columnClasses="width20,width40,width40">
<ice:outputText
value="#{userList.iappuserId}" />
<ice:outputText
value="#{userList.cappuserName}" />
<ice:outputText
value="#{userList.cappuserDesc}" />
</ice:panelGrid>
</f:facet>
</ice:selectInputText>
I am using Primefaces 5.3.5 with JSF 2.2.8. I see the same number of autocomplete result as my older version has in Icefaces 1.2 but I do not see user details. I see only number 0 in the first cell of each row.
<p:autoComplete id="searchUser" styleClass="adminAppUserSelect" value="#{appUserData.selectedUserName}"
maxResults="50" var="appUser" completeMethod="#{appUserData.completeUserList}"
binding="#{appUserData.userAutoComplete}" title="#{msg.WEB_ADMIN_PAGES_APPUSER_AUTOCOMPLETE}"
itemValue="#{appUser}" itemLabel="#{appUser.cappuserName}" converter="appUserConverter">
<!--<p:ajax event="itemSelect" listener="#{appUserData.updateListUser}"/>-->
<p:column>
<h:outputText value="#{appUser.iappuserId}" />
</p:column>
<p:column>
<h:outputText value="#{appUser.cappuserName}" />
</p:column>
<p:column>
<h:outputText value="#{appUser.cappuserDesc}" />
</p:column>
</p:autoComplete>
I am not sure about my converter that looks like
@FacesConverter("appUserConverter")
public class AppUserConverter implements Converter {
private int i;
@Override
public Object getAsObject(FacesContext fc, UIComponent uic, String value) {
...
}
@Override
public String getAsString(FacesContext fc, UIComponent uic, Object object) {
if(object == null)
return null;
else{
return ((VAppuser) object).getCappuserName();
}
}
}
my result of autoComplete component
Can you advise me, please what I made wrong?
UPDATED: I see that value(data-item-value) is set properly but label(data-item-label) is not set yet.
ADDED I noticed during debugging of my code that items
if(items != null) {
for(Object item : items) {
are correctly assigned to list that got from completeMethod but ac.getItemValue() passes object that has null properties at this line
String value = converter == null ? (String) ac.getItemValue() : converter.getAsString(context, ac, ac.getItemValue());
in the Primefaces AutoCompleteRenderer.