File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Murach's Java Servlets and JSP this week in the Servlets 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: 60739
    
  65

"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..

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calling bean method in enter press key
 
Similar Threads
[Spring] Doubt using customized property editor
primay key ???
action
Help Required
Highlighting a JTable cell on a successful search for a value entered in a textfield.