【发布时间】:2015-11-24 10:56:24
【问题描述】:
我正在使用 Richfaces 和 jsf。
我有一个看起来像这样的表格:
<h:form>
<h:inputText id="id1" value="#{mybean.1}" />
<h:commandButton id="button1" action="#{otherBean.goToPage1}">
<f:ajax execute="id1" render="id1" />
</h:commandButton>
<h:inputText id="id2" value="#{mybean.2}" />
<h:commandButton id="button2" action="#{otherBean.goToPage2}">
<f:ajax execute="id2" render="id2" />
</h:commandButton>
<h:inputText id="id3" value="#{mybean.3}" />
<h:commandButton id="button3" action="#{otherBean.goToPage3}">
<f:ajax execute="id3" render="id3" />
</h:commandButton>
</h:form>
我的问题是,当我在输入“id3”上写一些东西并按 ENTER 键时,“id1”的命令按钮正在读取。 或者我想要的是,当我在输入中按 Enter 时,好的 commandButton 正在读取(button1 的 input1,button2 的 input2,...)
对于我的项目,我只需要使用一种形式。
有人有想法吗?
【问题讨论】:
-
您忘记关闭
"id2"commandButton 组件。 -
谢谢,但问题仍然存在
-
解决你的问题...首先确保没有默认的命令按钮(如何在stackoverflow中进行搜索)。然后在 Stackoverflow 中寻找一个 Q/A 来检测输入中的 Enter-press 并通过 javascript 使“单击”右键。
-
如果我理解正确的话,表单上的第一个按钮是默认按钮。我尝试包含一些 javascript,但即使经过研究,我也找不到解决我问题的解决方案
-
“如果我理解正确,表单上的第一个按钮是默认按钮。”:正确