I use primefaces autocomplete and search properly. When I click Save ,Show this error message.
/entryPages/usDistributorDetails/Create.xhtml @95,71 itemLabel="#{territory.territoryName}": Property 'territoryName' not found on type java.lang.String
My xhtml code:
<p:autoComplete id="territoryId11"
value="#{usDistributorDetailsController.selected.territoryId}"
completeMethod="#{usDistributorDetailsController.completeTerritory}"
var="territory" itemLabel="#{territory.territoryName}"
itemValue="#{territory.territoryId}"
size="37"
style="width: 264px" >
</p:autoComplete>
My Java Code:
public List<UsTerritory> completeTerritory(String query11) {
List<UsTerritory> results = new ArrayList<UsTerritory>();
List<UsTerritory> territoryListA = getJpaTerritoryController().findUsTerritoryEntities();
for (UsTerritory abc : territoryListA) {
if (abc.getTerritoryName().startsWith(query11)) {
results.add(abc);
}
}
return results;
}
You might have to use a converter when working with POJOs. Take a look at: Primfaces Autocomplete Pojo