输入按键的行为类似于JSF中的提交 [英] Enter Key Press behave like Submit in JSF

查看:155
本文介绍了输入按键的行为类似于JSF中的提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使Enter键按下JSF中的提交行为。它适用于InputBoxes;但不是用inputSecret框

How to make Enter Key Press behave like Submit in JSF. It works with InputBoxes; but not with inputSecret boxes

推荐答案

如果你想按ENTER键而不是以任何形式提交,我们在这里要做什么是在af:form标签中添加defaultcommand属性,并将提交按钮的id作为值。此示例代码段是

If you want to press ENTER key instead of submit in any form, what we have to do here is add defaultcommand attribute in af:form tag and give id of the submit button as value. Sample code snippet for this is

<af:form id="f1" defaultCommand="cb1">
<af:outputText value="User Name" id="usename"/>
          <af:inputText value="#{BackingBean.userName}" id="uname" />
          <af:outputText value="Password" id="pword"/>
          <af:inputText value="#{BackingBean.password}" id="paword" secret="true"/>
          <af:commandButton text="Submit" action="#{BackingBean.method}" id="cb1" />
</af:form> 

这篇关于输入按键的行为类似于JSF中的提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆