You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by Apache Wiki <wi...@apache.org> on 2005/08/04 17:59:32 UTC
[Myfaces Wiki] Update of "SubmitPageOnValueChange" by ChristianEgli
Dear Wiki user,
You have subscribed to a wiki page or wiki category on "Myfaces Wiki" for change notification.
The following page has been changed by ChristianEgli:
http://wiki.apache.org/myfaces/SubmitPageOnValueChange
The comment on the change is:
Add another typ on how to do a submit from a search form field
------------------------------------------------------------------------------
Thanks to Slawek for this tip.
+ Here's another example provided by Bruno Aranda. It is doing a form submission with just a text field for something like a quick search. It works as follows:
+
+ 1. Include this javascript in the {{{<head>}}}
+ 1. Call the Javascript function from the attribute 'onkeypress' of your text field
+ 1. Include the hidden button, which will submit the form and with the id used in the onkeypress event
+
+ {{{
+ <script language="javascript">
+ function submitEnter(commandId,e)
+ {
+ var keycode;
+ if (window.event) keycode = window.event.keyCode;
+ else if (e) keycode = e.which;
+ else return true;
+
+ if (keycode == 13)
+ {
+ document.getElementById(commandId).click();
+ return false;
+ }
+ else
+ return true;
+ }
+ </script>
+
+ [...]
+
+ <h:inputField value="Hello" onkeypress="return submitEnter('submitLogin',event)"/>
+
+ [...]
+
+ <x:commandButton id="submitLogin" forceId="true" action="#{yourBean.whateverAction} style="visibility:hidden;" />
+ }}}
+