【发布时间】:2015-09-06 22:56:31
【问题描述】:
当用户按下enter 键时,我需要让我的primefaces p:commandLink 提交h:form。
我尝试了here 和其他几个地方建议的解决方案。我也试过primefacesdefaultCommand。无论我尝试什么,浏览器似乎都注意到按钮按下,但 action 没有执行。
这些是我的表单小部件:
<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" />
【问题讨论】:
-
定义“不走运”,更明确地说明什么不起作用并进行调试,以便了解原因
-
没有运气意味着表单没有提交。浏览器似乎注意到按钮按下,但未执行该操作。我也在编辑问题以反映这一点。
-
不,不会触发 onclick。
-
未提交仍含糊不清。参见例如QueryLars 的问题。那就是调试
-
我回答了 QueryLars 的问题。就像我说的,浏览器似乎注意到按下了“enter”,但是没有执行“home.goToSearchResults”这个动作。
标签: html jsf jsf-2 primefaces