This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • 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
Posts: 65537
108
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..

 
Power corrupts. Absolute power xxxxxxxxxxxxxxxx is kinda neat.
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!