How to set an action to primefaces keyboard's enter button

橙三吉。 提交于 2020-01-05 02:58:08

问题


I am new to JSF and PrimeFaces. I wish to use on-screen keyboard in my login page for my JSF project and I found primefaces keyboard. When I press the enter button in the primefaces keyboard, it doesn't work.

Even if I added onkeypress="if (event.keyCode == 13) #{usersBean.login()};"
I tried to add in <h:form> and the <p:keyboard>. It only work for pressing the physical enter button but not the one in the primefaces keyboard.

Below is the sample of my login page that using the primefaces keyboard:

<f:view>
<h:form id="loginForm" onkeypress="if (event.keyCode == 13) #{usersBean.login()};">
 <h2><h:outputText value="User Login"/></h2>
 <h:panelGrid columns="2" style=" padding-top: 20px">
         <h:outputLabel value="Email / ID:" for="userIdEmail" />
         <h:inputText id="userIdEmail" value="#{usersBean.userIdEmail}" title="Email / ID" required="true" requiredMessage="The Email / ID field is required." style="width: 200px"/>
         <h:outputLabel value="Password:" for="userPassword" />
         <p:keyboard id="userPassword" value="#{usersBean.loginPassword}" title="UserPassword" showMode="button" password="true" style="width: 195px" />  
</h:panelGrid>
<div>
     <h:commandButton id="loginButton" value="Login" action="#{usersBean.login()}" binding="#{usersBean.loginButton}" style="margin-right: 5px"/>

     <h:message for="loginButton" styleClass="errorStyle" style="text-align: center"/>
</div>
</h:form>
</f:view>

Anyone have any idea how to proceed to the login method after pressing the enter button in the primefaces keyboard?

来源:https://stackoverflow.com/questions/16919467/how-to-set-an-action-to-primefaces-keyboards-enter-button

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!