You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by "Jalapati, Nagendra" <na...@philips.com> on 2008/09/29 20:02:36 UTC

Call action on key board enter key

Hello Friends,

 

How to call managed bean action on pressing Enter Key on the key board?

 

I have a simple form with a text field and button. When user hits enter
key on the key board I should be able to call searchBean.orgSearch (same
action as commandButton)

 

I am using Myfaces1.1

 

<f:view>

<h:form id="searchForm">

<tr>

 

<td><h:inputText id="empName" size="30"

value="#{searchBean.employeeName}"></h:inputText></td>

          

<td>&nbsp;&nbsp;<h:commandButton styleClass="button" value="Go"

id="name_btn" type="submit"

action="#{searchBean.orgSearch}"></h:commandButton></td>

          

</tr>

</h:form>

</f:view>

 

All suggestions are welcomed...

 

Nag

 


RE: Call action on key board enter key

Posted by "Jalapati, Nagendra" <na...@philips.com>.
Thanks Andrew,

Appreciate your help!!

The wiki solution is working fine.

Nag

-----Original Message-----
From: Andrew Robinson [mailto:andrew.rw.robinson@gmail.com] 
Sent: Monday, September 29, 2008 2:13 PM
To: MyFaces Discussion
Subject: Re: Call action on key board enter key

I believe browsers automatically submit the form if a submit button is
found in the form. There are 2 wiki pages that could help you:

http://wiki.apache.org/myfaces/SubmitPageOnValueChange
http://wiki.apache.org/myfaces/JavascriptWithJavaServerFaces

-Andrew



On Mon, Sep 29, 2008 at 12:02 PM, Jalapati, Nagendra
<na...@philips.com> wrote:
> Hello Friends,
>
>
>
> How to call managed bean action on pressing Enter Key on the key
board?
>
>
>
> I have a simple form with a text field and button. When user hits
enter key
> on the key board I should be able to call searchBean.orgSearch (same
action
> as commandButton)
>
>
>
> I am using Myfaces1.1
>
>
>
> <f:view>
>
> <h:form id="searchForm">
>
> <tr>
>
>
>
> <td><h:inputText id="empName" size="30"
>
> value="#{searchBean.employeeName}"></h:inputText></td>
>
>
>
> <td>&nbsp;&nbsp;<h:commandButton styleClass="button" value="Go"
>
> id="name_btn" type="submit"
>
> action="#{searchBean.orgSearch}"></h:commandButton></td>
>
>
>
> </tr>
>
> </h:form>
>
> </f:view>
>
>
>
> All suggestions are welcomed...
>
>
>
> Nag
>
>

Re: Call action on key board enter key

Posted by Andrew Robinson <an...@gmail.com>.
I believe browsers automatically submit the form if a submit button is
found in the form. There are 2 wiki pages that could help you:

http://wiki.apache.org/myfaces/SubmitPageOnValueChange
http://wiki.apache.org/myfaces/JavascriptWithJavaServerFaces

-Andrew



On Mon, Sep 29, 2008 at 12:02 PM, Jalapati, Nagendra
<na...@philips.com> wrote:
> Hello Friends,
>
>
>
> How to call managed bean action on pressing Enter Key on the key board?
>
>
>
> I have a simple form with a text field and button. When user hits enter key
> on the key board I should be able to call searchBean.orgSearch (same action
> as commandButton)
>
>
>
> I am using Myfaces1.1
>
>
>
> <f:view>
>
> <h:form id="searchForm">
>
> <tr>
>
>
>
> <td><h:inputText id="empName" size="30"
>
> value="#{searchBean.employeeName}"></h:inputText></td>
>
>
>
> <td>&nbsp;&nbsp;<h:commandButton styleClass="button" value="Go"
>
> id="name_btn" type="submit"
>
> action="#{searchBean.orgSearch}"></h:commandButton></td>
>
>
>
> </tr>
>
> </h:form>
>
> </f:view>
>
>
>
> All suggestions are welcomed...
>
>
>
> Nag
>
>