Reputation: 57
Below is my code:
<h:form>
<p:autoComplete id="autoCompleteID" value="#{myBean.item}"
completeMethod="#{myBean.completeMethod}"
</p:autoComplete>
<h:commandButton action="#{myBean.searchRelatedItems}"/>
</h:form>
Here my scenario is like standard Google search, I can see related Items in suggestion and also redirect another page based on text typed in p:autoComplete text field. Its works fine by click on Button, but I also want to achieve by hitting ENTER in p:autoComplete text field.
Upvotes: 2
Views: 1948
Reputation: 637
A late answer, but I will just leave it here...
onkeyup="if (event.keyCode === 13) { document.getElementById('searchForm:search-button').click(); return false; }"
Similar topic: Submit form with primefaces widgets on enter
Upvotes: 1