• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Form and commandButton

 
Johan Rignas
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Johan Rignas
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe Chrome is "IE Compatible"???
 
Johan Rignas
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic