primefaces autocomplete event itemSelect listener value null in ManagedBean

依然范特西╮ 提交于 2019-12-23 16:27:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!