且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

输入按键的行为类似于JSF中的提交

更新时间:2022-05-05 23:14:58

如果你想按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>