Jsf 2 通过在primefaces中点击ENTER事件提交表单p:autoComplete
下面是我的代码:Jsf 2 通过在primefaces中点击ENTER事件提交表单p:autoComplete,jsf-2,primefaces,Jsf 2,Primefaces,下面是我的代码: <h:form> <p:autoComplete id="autoCompleteID" value="#{myBean.item}" completeMethod="#{myBean.completeMethod}" </p:autoComplete> <h:commandButton action="#{myBean.searchRelatedItems}"/&g
<h:form>
<p:autoComplete id="autoCompleteID" value="#{myBean.item}"
completeMethod="#{myBean.completeMethod}"
</p:autoComplete>
<h:commandButton action="#{myBean.searchRelatedItems}"/>
</h:form>
迟来的回答,但我会把它留在这里
- 尝试使用PrimeFacesCommandButton,它是p:commandButton,而不是h:commandButton
- 确保commandButton的属性类型为“提交”,而不是“按钮”,“提交”是Primefaces中的默认值
- 最后,一个特定的(但我认为是讨厌的)解决方案是在commandButton处放置一个id,如“search button”,在h:form处放置一个id,如“searchForm”,并在p:autoComplete或h:form
onkeyup=“if(event.keyCode==13){document.getElementById('searchForm:search button')。click();return false;}”
类似的话题:我面临着同样的问题,请帮我解决……我已经在某某身上看到了完全相同的问题,也没有回答。。。一个不完全有效的解决方法是在表单中添加“”。如果按ESC键隐藏自动完成选择覆盖,则可以按enter键提交表单。但这仍然是一个问题。。。