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/26 21:43:38 UTC

Myfaces action on pressing 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: Myfaces action on pressing Enter Key

Posted by Andrew Robinson <an...@gmail.com>.
Are there two threads for this subject?

Here is my reply on the other thread:

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:07 PM, Jalapati, Nagendra
<na...@philips.com> wrote:
> Yes, my issue is the second case.
>
> When enter is clicked any where in the form, I should be able to call the
> same action as below <h:commandButton
>
>
>
> <h:commandButton styleClass="button" value="Go" id="name_btn" type="submit"
> action="#{searchBean.orgSearch}"></h:commandButton>
>
>
>
> Nag
>
>
>
>
>
>
>
> ________________________________
>
> From: Grzesiek [mailto:gregory.d3@gmail.com]
> Sent: Monday, September 29, 2008 2:02 PM
> To: MyFaces Discussion
> Subject: Re: Myfaces action on pressing Enter Key
>
>
>
> If you press 'enter' when your cursor is on form field, the form will be
> submited - no problem - so I  suppose that it's NOT what you are thinking
> about.
>
> BUT If you would like to submit form whenever enter is pressed, the only one
> way is to use javascipt and sth like  'click hidden link'.
>
> regards
> Grzesiek
>
> 2008/9/26 Jalapati, Nagendra <na...@philips.com>
>
> 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: Myfaces action on pressing Enter Key

Posted by "Jalapati, Nagendra" <na...@philips.com>.
Yes, my issue is the second case. 

When enter is clicked any where in the form, I should be able to call
the same action as below <h:commandButton

 

<h:commandButton styleClass="button" value="Go" id="name_btn"
type="submit" action="#{searchBean.orgSearch}"></h:commandButton>

 

Nag

 

 

 

________________________________

From: Grzesiek [mailto:gregory.d3@gmail.com] 
Sent: Monday, September 29, 2008 2:02 PM
To: MyFaces Discussion
Subject: Re: Myfaces action on pressing Enter Key

 

If you press 'enter' when your cursor is on form field, the form will be
submited - no problem - so I  suppose that it's NOT what you are
thinking about.

BUT If you would like to submit form whenever enter is pressed, the only
one way is to use javascipt and sth like  'click hidden link'.

regards
Grzesiek



2008/9/26 Jalapati, Nagendra <na...@philips.com>

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: Myfaces action on pressing Enter Key

Posted by Grzesiek <gr...@gmail.com>.
If you press 'enter' when your cursor is on form field, the form will be
submited - no problem - so I  suppose that it's NOT what you are thinking
about.

BUT If you would like to submit form whenever enter is pressed, the only one
way is to use javascipt and sth like  'click hidden link'.

regards
Grzesiek


2008/9/26 Jalapati, Nagendra <na...@philips.com>

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