This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JSF and the fly likes Calling bean method in enter press key Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Calling bean method in enter press key" Watch "Calling bean method in enter press key" New topic
Author

Calling bean method in enter press key

Thill Sivam
Greenhorn

Joined: Oct 14, 2009
Posts: 9
Hi All,

<h:inputText value="#{bean.keyword}" />
<h:commandButton action ="#{bean.search}" value="Search"/>

On clicking the search button, search method in bean is called..

i want when the user types the keyword in text box and presses the enter key , form should be submitted as well as bean method should be called for searching.

Is that possible ? Thanks in advance.
Joe ONeil
Greenhorn

Joined: Jan 16, 2009
Posts: 12
Yes

<h:inputText value="#{bean.keyword}" onblur ="document.getElementById('formName:btn1').click();"/>


<h:commandButton action ="#{bean.search}" value="Search" id="btn1"/>

When the value change it gets the bean id and fire the click event
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61084
    
  66

"cybertech techies", please check your private messages for an important administrative matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Thill Sivam
Greenhorn

Joined: Oct 14, 2009
Posts: 9
HI Joe ONeil ,
Thanks for the solution..

 
jQuery in Action, 2nd edition
 
subject: Calling bean method in enter press key