问题描述
我需要我的 primefaces
p:commandLink
提交 h:form
当用户按下输入
键时。
I need to have my primefaces
p:commandLink
submit a h:form
when the user presses the enter
key.
我尝试了解决方案建议和其他几个地方。我也尝试了 primefaces
defaultCommand
。无论我尝试什么,浏览器似乎都注意到按钮按下了,但操作
未执行。
I tried the solutions suggested here and in a couple of other places. I also tried the primefaces
defaultCommand
. No matter what I try, the browser seems to notice the button press, but the action
is not performed.
这些是我窗体的小部件:
These are my form's widgets:
<p:autoComplete id="acSimple" value="#{home.searchKeywords}" completeMethod="#{home.completeText}" style="" />
<p:commandLink id="srchbutton" action="#{home.goToSearchResults}" onclick=" $('.prgrs').show();">
<h:graphicImage id="srch" name="images/searchbutton.jpg" class="img-responsive" style="display: inline-block; margin-left:0px; margin-bottom:-0px;" />
</p:commandLink>
<p:defaultCommand target="srchbutton" />
推荐答案
< h:form onkeypress =if(event.keyCode == 13){document.getElementById('form:srchbutton')。click(); return false;}>
请确保您的链接的真实ID是form:srchbutton或放置它。
您可以使用开发人员工具或萤火虫找出它。
Make sure your real id of link is "form:srchbutton" or put whatever it is.You can use developer tools or firebug to find it out.
这篇关于在输入时使用primefaces小部件提交表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!