JSF validation and multiple forms
When the are multiple forms on page and one fails on validation then if I submit another form the first does not reload its values from JavaBeans but keeps values that does not past validation previous.
How can i change this behavior?
Test case: (step-by-step)
1. Open page
2. Remove text in second input control (it sould be empty) and press second submit button.
3. Now you see "Validation Error: Value is required."
4. Put text in first input control and press first submit button.
5. Now you don't see text "Good thing" in second input control.
This is unexpected behavior.
6. Put text in second input control and press submit
7. Now you can see "Good thing" here
file test.jspx
<f:view
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
locale="en"
>
<jsp:directive.page contentType="text/html;charset=UTF-8" language="java"/>
<jsp:output
omit-xml-declaration="true"
doctype-root-element="html"
doctype-public="-//W3C//DTD HTML 4.01//EN"
doctype-system="http://www.w3.org/TR/html4/strict.dtd"/>
<html>
<head>
</head>
<body>
<h:form id="form1">
<h:inputText id="value1" value="#{test.value1}"/>
<h:commandButton value="First Submit"/>
</h:form>
<h:form id="form2">
<h:inputText id="value2" value="#{test.value2}" required="true"/>
<h:commandButton value="Second Submit"/>
</h:form>
<div style="border:1px solid red;">
<h:messages/>
</div>
</body>
</html>
</f:view>
file TestBean.java
package test;
/**
* User: vvavrychuk
*/
publicclass TestBean{
private String value1;
private String value2;
public String getValue1(){
return value1;
}
publicvoid setValue1(String value1){
this.value1 = value1;
}
public String getValue2(){
return"Good thing";
}
publicvoid setValue2(String value2){
this.value2 = value2;
}
}
file faces-confing.xml
<managed-bean>
<managed-bean-name>test</managed-bean-name>
<managed-bean-class>test.TestBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>

