primefaces: resetValues="true" not working after form validation errors
Describe the bug
Follow these steps with the reproducer code to see the behaviour:
- Type something in the first inputtext.
- Click on “Save” (the message indicating that the string2 is required will be shown).
- Click on “Clean” (it won’t work and it won’t clean the values)
- Type something in the second inputtext.
- Click on “Save”.
- Click on “Clean” (now it will work and both boxes will be cleared).
I’m testing the same behaviour in an application with primefaces 10 and it works great, I cannot tell in what version of Primefaces/JSF this got broken.
Reproducer
XHTML:
<h:form>
<p:inputText value="#{bean.string1}" required="true"/>
<p:inputText value="#{bean.string2}" required="true"/>
<h:commandButton value="Save">
<p:ajax process="@form" update="@form" listener="#{bean.save}" />
</h:commandButton>
<h:commandButton value="Clean">
<p:ajax update="@form" listener="#{bean.clean}" resetValues="true"/>
</h:commandButton>
</h:form>
BEAN:
private String string1;
private String string2;
public void save() { }
public void clean() {
this.string1 = null;
this.string2 = null;
}
public String getString1() {
return this.string1;
}
public void setString1(String string1) {
this.string1 = string1;
}
public String getString2() {
return this.string2;
}
public void setString2(String string2) {
this.string2 = string2;
}
Expected behavior
The button “Clean” should always work.
PrimeFaces edition
None
PrimeFaces version
14.0.5
Theme
No response
JSF implementation
Mojarra
JSF version
4.1.0
Java version
17
Browser(s)
Chrome 129
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 30 (16 by maintainers)
We have overrided the class in the meantime, it is easier than replacing every XHTML.
I was asking just for curiosity 😉
Thank you both for your answers, and we will keep waiting until Mojarra releases their update.