I have forms in JSF with some keyboard shortcuts, for example, CTRL + S triggers submit to save the data.
The problem is that when a key combination is pressed in a <p:selectOneMenu>
field, the first item starting with S
(as the example) is selected and then the form is submitted.
You can reproduce this behavior by accessing the showcase by selecting the first field and pressing CTRL + O . In Chrome, at least it will select the first option and then open the "Open File" dialog.
My intent is for the component to ignore the letter you typed if a special key is pressed.
I tested the html SELECT
component and the jQuery UI combo and the same behavior does not occur. By the way, PrimeFaces uses a different wrapper for a input
field.
I tried to add a return false
to both the onkeydown
and onkeyup
events according to the User Guide. Nothing done.
I've even tried adding jQuery keyboard events with preventDefault()
and return false
. Nothing.
Well, before you download the source of PrimeFaces and start sniffing, does anyone have any idea how to circumvent this situation?
Update
More details about the component.
Opening the showcase page , clicked on the first component and left the SELECT
open.
/ p>
I pressed F12 to open the console and typed document.activeElement
. The result was input
:
<input id="j_idt18:j_idt22_focus" name="j_idt18:j_idt22_focus" type="text" readonly="readonly">
I understand that this is the field that actually takes the value and receives the events. It should have an event handler that selects the item when you press a letter, but it certainly lacked a treatment for the special keys like CTRL and SHIFT .