| Author |
Form and commandButton
|
Johan Rignas
Ranch Hand
Joined: Jul 17, 2011
Posts: 30
|
|
|
Hi. I have a Form containing some inputTexts and one commandButton. Is there any simple way to make the "Enter"-key make the commandButton to trigger? It feels very very inefficient to have a "onkeydown" listeners for every textfield that listens to every key press.... Any ideas?
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14456
|
|
Yes, but there's a catch. In most web browsers, when you have a single submit button, pressing "Enter" will submit the form.
However, the old offender: Internet Explorer, won't do that. So you have to put in browser-specific hacks. They're just gnarly enough that I don't remember the details, but you can Google for them. It's an HTML problem, not a JSF problem, so non-JSF apps have the save troubles.
|
Customer surveys are for companies who didn't pay proper attention to begin with.
|
 |
Johan Rignas
Ranch Hand
Joined: Jul 17, 2011
Posts: 30
|
|
I´m not convinced. I´m using Chrome and this dose not trigger the button when I press "Enter" in selected textField:
I´m missing something? Should this work?
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14456
|
|
Maybe Chrome is "IE Compatible"???
|
 |
Johan Rignas
Ranch Hand
Joined: Jul 17, 2011
Posts: 30
|
|
Probably. But when trying the same code with firefox the "Enter"-key still dose not trigger the "action"....
My only guess is that I´m missing something...
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14456
|
|
If the page is literally as you displayed it, it's probably because you have no actual input (no "value=" reference on the inputText element).
|
 |
 |
|
|
subject: Form and commandButton
|
|
|