Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF: Hitting Enter on an inputText component

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ammendment, it work fine in Firefox. IE is where I am having the problem.
 
Kito Mann
author
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the same exact problem. Any fixes found yet?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic