-
1. Re: how to invoke a me method while click enter key
lvdberg Oct 28, 2009 5:28 PM (in response to thiagu.m)Hi,
Use the onkeyup or -down events to handle the keyboard events. Be aware that it creates an Ajax-request for every click, so it is wise to add a queue to capture/maximize the key-events you would like to handle. See the RichFaces manual, which includes a very good piece of documentation about the queues.
Leo
-
2. Re: how to invoke a me method while click enter key
kragoth Oct 29, 2009 12:24 AM (in response to thiagu.m)It doesn't need to be complex to do what you are asking for.
No need for queues, and you can avoid an ajax request per keypress.a4j:support tags have the onsubmit attribute. If the javascript put on this line returns false then the ajax request will not fire. So, all you have to do is check what key was pressed and if is not enter or tab return false. (I'm not sure if the event is passed into that javascript or not, but I'm sure you can work it out :)
Now, all that being said. You should probably have a look at queues anyway if you are using ajax, because otherwise eventually you are going to get concurrent access exceptions.
-
3. Re: how to invoke a me method while click enter key
kragoth Oct 29, 2009 12:30 AM (in response to thiagu.m)Oh I should have said, use the onkeyup event in your a4j:support tag
So, you'll end up with something like this :S (you'll need to figure out the javascript part yourself as this would only work in IE I think.)
<h:inputText ....> <a4j:support event="onkeyup" onsubmit="if (window.event.keyCode == 9 || window.event.keyCode == 13) {return true;} return false;" action="#{whatever your action is}"/> </h:inpuText
Something like that. But, you will probably want to work on that javascript a bit. It is not tested and not cross browser compatible.
Hope all goes well
-
4. Re: how to invoke a me method while click enter key
thiagu.m Oct 29, 2009 8:19 AM (in response to thiagu.m)thank you for all replies.
the above script is not working in firefox,
so we need to use window.event.which instead of window.event.keyCode.