【发布时间】:2011-11-28 17:45:32
【问题描述】:
我有一个表单和两个命令按钮。我希望在按下回车键时,第二个 commandButton 被按下,但第一个 commandButton 被按下。
请考虑以下示例代码。
<h:form>
<p:inputtext value="#{bean.mobileNumber}" />
<p:commandButton id="startNewChat" value="Chat" action="#{bean.startNewChat}" update="chatWindow" />
<br />
<br />
<p:outputPanel id="chatWindow">
<p:inputTextarea readonly="true" value="#{bean.chatMessages}" />
<p:inputText value="#{bean.newChatMessageFromWeb}" />
<p:commandButton id="submitChatMessage" action="#{bean.submitChatMessage}" value="Send Message" />
</p:outputPanel>
</h:form>
当按下 Enter 键时,第一个 commandButton(with id="startNewChat") 被按下,但我希望第二个 commandButton(with id="submitChatMessage") 应该被按下。
我尝试过的: accesskey="13", type="submit", id="submit"
【问题讨论】:
-
您想将此应用于所有输入字段还是仅应用于
id="chatWindow"中的一个? -
@BalusC,id="chatWindow" 中的字段。这是一个示例代码,在原始代码中,我有更多字段......谢谢
标签: jsf-2 primefaces