Maybe I'm misunderstanding the functionality of this component but I expect that all values in my Bean will be validated but this is not happening. Here is some sample code illustrating the behavior I'm seeing:
<h:form id="myForm">
<rich:graphValidator value="#{testBean}" id="gv">
<h:panelGrid columns="3">
<h:inputText value="#{testBean.str}"></h:inputText>
<h:inputText value="#{testBean.date1}" styleClass="datepicker"></h:inputText>
<h:inputText value="#{testBean.date2}" styleClass="datepicker"></h:inputText>
</h:panelGrid>
<a4j:commandButton value="Submit" action="#{testBean.doAction}"/>
</rich:graphValidator>
</h:form>
@ManagedBean
@ViewScoped
public class TestBean implements Cloneable, Serializable{
private static final long serialVersionUID = 1952428504080910113L;
private String str="";
@Pattern(regexp="(^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\\d\\d$)?", message="Invalid date")
private String date1;
@Pattern(regexp="(^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\\d\\d$)?", message="Invalid date")
private String date2;
@AssertTrue(message = "Invalid value")
public boolean isStrValid() {
return str.length() == 9 || str.isEmpty();
}
Assuming I enter invalid text in all 3 of the fields I've defined above I would expect to see 3 error messages, 2 for "Invalid date" and 1 for "Invalid value". This is not happening, instead I am seeing 2 "Invalid date" error messages. The only way I can get the "Invalid value" error message to show is by either leaving the 2 date fields blank or by entering valid values in the 2 date fields. If I enter an invalid value in either date field the "Invalid value" message will not show.
Does anyone know why this happens?