• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling bean method in enter press key

 
Thill Sivam
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"cybertech techies", please check your private messages for an important administrative matter.
 
Thill Sivam
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Joe ONeil ,
Thanks for the solution..

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic