aspose 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
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: 61612
    
  67

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

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Calling bean method in enter press key