When the autoComplete contains both Ajax events, the behavior of the keyboard enter and the mouse click become different when selecting from the autoComplete selection list. If the desired item is highlighted on the list and the enter key is pressed, the itemSelect event is processed and the bean's selection process is executed correctly. If, however, the mouse is clicked, the change event is executed first and the itemSelect event is never executed.
Primefaces 5.2 and 6.1 both tested and found to be the same
HTML code:
Code: Select all
<p:column styleClass="dataEntryField">
<p:autoComplete
value="#{ssCgWebUserPassword0001.enteredWebUserId}" id="i0"
autocomplete="off" maxlength="20" size="25" immediate="false"
widgetVar="webId" maxResults="15" minQueryLength="1"
queryDelay="300"
completeMethod="#{ssCgWebUserPassword0001.completeWebIdLookup}">
<p:ajax update="i0, m0,:javaScriptResponseForm "
event="itemSelect"
listener="#{ssCgWebUserPassword0001.selectWebUserId}" />
<p:ajax update="i0,m0, :javaScriptResponseForm" event="change"
listener="#{ssCgWebUserPassword0001.editWebUserId}" />
</p:autoComplete>
<p:message for="i0" id="m0" display="text" />
</p:column>
,
Code: Select all
public List<String> completeWebIdLookup (String startingCharacters) {
List<String> listOfIds = new ArrayList<>();
listOfIds = webSecurityService.populateAutoCompleteList(startingCharacters);
return listOfIds;
}
public void selectWebUserId () {
selectedWebSecurity = webSecurityService.retrieveWebSecurityByWebUserId(enteredWebUserId);
if (selectedWebSecurity == null || NumberUtil.isNullOrZero(
selectedWebSecurity.getWebSecurityNtty().getWebSecuritySerial())) {
FacesContextUtil.createErrorMessage(
super.getELEMENT_ID().f1_i0, MESSAGE_KEY.recordNotFound);
focusOn(super.getELEMENT_ID().f1_i0_input);
selectedWebSecurity = new WebSecurityBO();
return;
} else {
super.getConversation().setAttribute(super.getCONVERSATION_KEY().selectedWebSecurity,
selectedWebSecurity);
FacesContextUtil.redirect(LINK.ssCgWebUserPassword0002);
}
}
public void editWebUserId() {
// no edits
}