-
1. Re: Why does Enter reloads RichFaces-page?
healeyb Jun 15, 2012 5:42 AM (in response to grattler)Hi, you can disable form submit on enter using this:
<h:inputText onkeydown=”return event.keyCode!=13″ ... - any problems with this try onkeypress=
You could make the enter key behave like a tab, i.e. move to next input field with this:
<h:inputText onkeydown="if (event.keyCode == 13) event.keyCode = 9;"
In fact you can add onkeydown/onkeypress to the <h:form> rather than every input field and so save
yourself some typing.
Regards,
Brendan.
-
2. Re: Why does Enter reloads RichFaces-page?
grattler Jun 15, 2012 8:24 AM (in response to healeyb)Hi Brendan,
onkeydown=”return event.keyCode!=13″ works on both elements: <h:inputText> and <h:form>.
The following does not work:
<h:inputText onkeydown="if (event.keyCode == 13) event.keyCode = 9;"
Anyway, the first solution is great and solves my problem.
Thank you very much for the quick answer.
Kind regards
Oliver
-
3. Re: Why does Enter reloads RichFaces-page?
healeyb Jun 15, 2012 8:46 AM (in response to grattler)Ok great. Just to clarify, onkeydown="if (event.keyCode == 13) event.keyCode = 9;" should change the enter into a
tab, and move the input focus to the next input component on the page. I often set the input focus to the first input
component on page load, then on all but the last input component change enter into a tab. But then allow the default
behavior on the last input component on the assumption that by the time the user has got there they will have input
all the other information.
If you're partially submitting a form with ajax then instead of allowing the default behavior on the last input component
(full form submit) then you can .click() an ajaxified commandButton/Link instead.
Regards,
Brendan.