I have a p:commandButton
that actually is the logout button. It is placed in the north p:layoutUnit
and if I press the enter key in any form it always log me out. I dont want that button to respond the enter key. How to do that?
Asked
Active
Viewed 4,168 times
4

Kaz Miller
- 949
- 3
- 22
- 40
2 Answers
6
Put a hidden button with no action in the logout form and capture the enter key via p:defaultCommand
.
<p:defaultCommand target="dummy"/>
<p:commandButton id="dummy" process="@none" global="false" style="display:none;"/>

user1983983
- 4,793
- 2
- 15
- 24
5
Nest the button within this form tag:
<h:form id="thisform" onkeypress="if( event.keyCode == 13){event.keyCode=0;}">

Josef E.
- 2,179
- 4
- 15
- 30