问题
I am using Primefaces 3.4.2 Autocomplete.
In ManagedBean when I select a row as I type characters in autocomplete, I am not able to get the value in method handleSelect(SelectEvent event) {
What could be the reason for this? Ideally I would like to fill or populate other columns in jsf page when I select a row from autocomplete values.
JSF code for autocomplete
<p:autoComplete value="#{empMB.selectedEmployee}"
id="basicPojo" minQueryLength="3"
completeMethod="#{myMB.complete}" var="p"
itemLabel="#{p.empName}"
converter="#{employeeNameConverter}"
forceSelection="true" >
<p:ajax event="itemSelect"
listener="#{myMB.handleSelect}" />
ManagedBean method
public void handleSelect(SelectEvent event) {
String value = (String) event.getObject();
System.out.println("selected "+value);
回答1:
The reason is you didn't provide itemValue attribute in p:autoComplete component.
来源:https://stackoverflow.com/questions/14746429/primefaces-autocomplete-event-itemselect-listener-value-null-in-managedbean