I have a situation where I would like the JSF validation to occur only if the user actually changed the values present in the form.
For example, imagine an forum's profile management form. The field that allowed email address updates would probably look something like this.
<h:inputText value="#{userBean.email}"/>
This text field will display the email address and allow changes.
When the form is submitted, I only want to fire the validators if the user actually changed data in the form. This sounds odd, I know. Let me explain further. Of course, if the user already has this email address, the data in it should be valid. However, what if my validator hits an LDAP server to make sure this address is unique. If the user never changed this data, the LDAP server will see the address as already in use.
I see two options:
1) I can "tell" the validator what the initial value is using an attribute like "initialValue", which would take the same EL as the inputText would for its value attribute. With this knowledge, the validator could skip all actual validation checks if the current value matches the initialValue.
2) I can find some way to enable validation only on changed components. I'm not even sure this is possible using JSFs validation capabilities.
I'm fine with option 1, but would like to know if option 2 was possible before I made a decision.