i have a small problem with my jsf form. i made an example registration form with a submit button and a reset button:
The HTML <input type="reset">
element as generated by <h:commandButton type="reset">
does not clear the input values of the form. Instead, it resets the input values of the form to their initial values as they are in the initially obtained HTML source code. When you do a render="@form"
, whereby you basically ajax-update the HTML source code of the entire form, all those input fields will now contain the submitted values in the HTML source code. As evidence that the reset button "works fine", try editing those submitted values once again before pressing the reset button.
You've basically 2 options:
Don't use render="@form"
. Render only explicitly those messages. E.g.
<h:message id="m_username" for="username" ... />
<h:message id="m_password" for="password" ... />
...
<f:ajax ... render="m_username m_password ..." />
It's only a hell lot of work to specify them all if you have many of them. If you're using PrimeFaces, PrimeFaces Selectors may come into rescue.
<h:message for="username" styleClass="message" />
<h:message for="password" styleClass="message" />
...
<p:ajax ... update="@(.message)" />
Refresh the page by a GET button.
<h:button value="Reset" />