You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Hailong Zhang <to...@gmail.com> on 2006/08/06 06:56:09 UTC
How to define the default action of a form?
I have a search bar contains a TextBox and a CommandLink. When user hit
"Enter" in the TextBox, I don't know what happens, it seems that it refresh
the page. Instead, I want to submit the form when "Enter" is hit, behave the
same as use click the CommandLink.
I have tried "j4j Tag Library, defaultAction", but it doesn't work.
Any solutions?
Thanks in advance.
Regards,
Toby
Re: How to define the default action of a form?
Posted by Hailong Zhang <to...@gmail.com>.
Hi Andrew,
It's helpful, thank you very much!
Regards,
Toby
2006/8/7, Andrew Robinson <an...@gmail.com>:
>
> You can use JavaScript -- it is what I have done. Check out [1] and
> look for the "clickLink" functionality. Then use a keyPress event to
> look for \n or \r (I think most or all browsers use \r as enter
> though), and then 'click' the link. The page below [2] is an excellent
> reference and this specific page shows, in a cross-browser way, to get
> which key has been pressed.
>
> There may be easier ways, but this is by far more useful. You can trap
> the escape key, arrow keys, etc. and be able to make a better user
> experience.
>
> -Andrew
>
> [1] http://wiki.apache.org/myfaces/JavascriptWithJavaServerFaces
> [2] http://www.quirksmode.org/js/events_properties.html
>
> On 8/5/06, Hailong Zhang <to...@gmail.com> wrote:
> > I have a search bar contains a TextBox and a CommandLink. When user hit
> > "Enter" in the TextBox, I don't know what happens, it seems that it
> refresh
> > the page. Instead, I want to submit the form when "Enter" is hit, behave
> the
> > same as use click the CommandLink.
> > I have tried "j4j Tag Library, defaultAction", but it doesn't work.
> >
> > Any solutions?
> >
> > Thanks in advance.
> >
> > Regards,
> > Toby
> >
>
Re: How to define the default action of a form?
Posted by Andrew Robinson <an...@gmail.com>.
You can use JavaScript -- it is what I have done. Check out [1] and
look for the "clickLink" functionality. Then use a keyPress event to
look for \n or \r (I think most or all browsers use \r as enter
though), and then 'click' the link. The page below [2] is an excellent
reference and this specific page shows, in a cross-browser way, to get
which key has been pressed.
There may be easier ways, but this is by far more useful. You can trap
the escape key, arrow keys, etc. and be able to make a better user
experience.
-Andrew
[1] http://wiki.apache.org/myfaces/JavascriptWithJavaServerFaces
[2] http://www.quirksmode.org/js/events_properties.html
On 8/5/06, Hailong Zhang <to...@gmail.com> wrote:
> I have a search bar contains a TextBox and a CommandLink. When user hit
> "Enter" in the TextBox, I don't know what happens, it seems that it refresh
> the page. Instead, I want to submit the form when "Enter" is hit, behave the
> same as use click the CommandLink.
> I have tried "j4j Tag Library, defaultAction", but it doesn't work.
>
> Any solutions?
>
> Thanks in advance.
>
> Regards,
> Toby
>