| Author |
JSF: Hitting Enter on an inputText component
|
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15229
|
|
I noticed that if I have an inputText control and a commandButton, hitting enter on the textfield just does a postback, whereas, on a non JSF driven page, hitting enter just submits the default button on the page. Does this mean that I must also supply a listener on the inputText control that calls the same method in my bean as the commandButton?
|
 |
Kito Mann
author
Ranch Hand
Joined: Dec 11, 2003
Posts: 103
|
|
Originally posted by Gregg Bolinger: I noticed that if I have an inputText control and a commandButton, hitting enter on the textfield just does a postback, whereas, on a non JSF driven page, hitting enter just submits the default button on the page. Does this mean that I must also supply a listener on the inputText control that calls the same method in my bean as the commandButton?
Gregg, I'm not quite sure what you mean -- hitting enter on a JSF form usually defaults to the first button, like any other HTML form. Let's say you had a navigation rule like this: And you have a page like this: If you hit enter, it'll execute the "default" button, and try to load "anotherpage.jsp". If you click on the "not default" button, it'll simply redisplay the page.
|
Kito D. Mann
Author of JSF in Action — www.JSFCentral.com - JSF FAQ, news, and info
|
 |
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15229
|
|
Well, I have something strange happening. I have a login page and after I type my username and password I hit and enter and everything works fine. I have another page with a single textfield and a button for looking up an employee by their ID number. I type in the ID and hit enter and the page just posts back to itself. If I click the Button, it works as expected, navigating to another page. There is nothing else on the page except a label.  [ September 02, 2004: Message edited by: Gregg Bolinger ]
|
 |
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15229
|
|
|
Ammendment, it work fine in Firefox. IE is where I am having the problem.
|
 |
Kito Mann
author
Ranch Hand
Joined: Dec 11, 2003
Posts: 103
|
|
Originally posted by Gregg Bolinger: Ammendment, it work fine in Firefox. IE is where I am having the problem.
Hmmm.. What version of IE do you have? And can you show us the page you're having a problem with?
|
 |
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15229
|
|
I have IE 6.0. Here is the employeelookup.jsp: And here is the EmployeeLookupBean.java Here is the Navigation Rule: The only difference between the way I constructed this page and the way I constructed the login page is that this page has a header which has some commandLinks in them. Could it be that one of the commandLinks is taking the default away from my Lookup commandButton? But then again, why would it work in Firefox and not IE if this was the case?  [ September 03, 2004: Message edited by: Gregg Bolinger ]
|
 |
Colin Gajraj
Greenhorn
Joined: Aug 25, 2010
Posts: 1
|
|
|
I have the same exact problem. Any fixes found yet?
|
 |
 |
|
|
subject: JSF: Hitting Enter on an inputText component
|
|
|