问题
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