I am working on a Java EE project and using Primefaces. I try to show search operation results by group. In order to show results, I am using primefaces autocomplete facet. I reach some consequences but the problem is that same groups are repeating as you see below.('0002','000' groups repeated)
<p:autoComplete id="generalSearch" completeMethod="#{search.afterSearch}" minQueryLength="3"
var="doc" itemLabel="#{doc.get('NAME')}" itemValue="#{doc}" forceSelection="true" groupBy="#{doc.get('CODE')}"
converter="searchConverter" scrollHeight="500"
effect="blind" styleClass="SearchText" placeholder="Search"/>
Here is my SearchConverter class
@FacesConverter("searchConverter")
public class SearchConvert implements Converter {
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
if(value != null && value.length() > 0) {
try {
SearchBean sBean = (SearchBean) context.getExternalContext().getSessionMap().get("search");
System.out.println("VALUE " + value);
return sBean.getDocs().get(Integer.parseInt(value));
} catch(NumberFormatException e) {
Log.debug("ERROR");
throw new ConverterException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Conversion Error", "Not a valid theme."));
}
}
else {
return null;
}
}
@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
if(value != null) {
return (String) ((SolrDocument) value).get("id");
}
return null;
}
}
I am not sure getAsObject
function whether is working or not. Because I can't see the output of System.out.println("VALUE " + value);
Ohh wait primeface doesn't check the other groups just before one.
So use group by
when you execute select command