Consider the snippet:
<h:form>
<hr/>
<h:panelGrid columns="3">
Name:
<h:inputText id="nameId" value="#{ajaxBean.name}"
validator="nameValidator"
f5:placeholder="Enter your name ..."/>
<h:message id="msgNameId" showDetail="true"
showSummary="true" for="nameId"
style="color: red;"/>
Surname:
<h:inputText id="surnameId" value="#{ajaxBean.surname}"
validator="nameValidator"
f5:placeholder="Enter your surname ..."/>
<h:message id="msgSurnameId" showDetail="true"
showSummary="true" for="surnameId"
style="color: red;"/>
</h:panelGrid>
<h:commandButton value="Submit">
<f:ajax execute="@form"
render="@form" listener="#
{ajaxBean.upperCaseNameAndSurname()}"/
</h:commandButton>
<h:commandButton value="Cancel">
<f:ajax execute="@this"
render="@form"/>
</h:commandButton>
<h:commandButton value="Clear/Reset">
<f:ajax execute="@this"
render="@form"
listener="#{ajaxBean.cancelNameAndSurname()}"/>
</h:commandButton>
</h:form>
resetValues= "true"
seems to work only if one mentions the component ids
explicitly inside the render
attribute of the <f:ajax>
for the Submit
button.
i.e render="nameId msgNameId surnameId msgSurnameId"
rather than render="@form"
What exactly is the difference b/w these 2 forms?
The invalid values are still there after re-render
if the value is (@form)
for render
attribute for Submit
button.
I definitely remembered one of the comments by BalusC,
When validations phase has failed due to a conversion or validation error anywhere, components which
successfully
passed validation will returnlocal value
and components whichfailed
validation will returnsubmitted value
.
If the name is valid and the surname is not (or any other combination involving invalid values), then after submit
and clear/ reset
, the input field*(i.e the valid field)* for the name is not cleared. Even though the whole form
was re-rendered
, I see only the field for which validation failed was cleared. Why?
Does the above comment signifies some relation with the above problem?
The cancelNameAndSurname
method just do this thing-
name = ""
surname = ""
I know for sure that one of the solutions to resolve this is -
<f:actionListener type="org.omnifaces.eventlistener.ResetInputAjaxActionListener"/>