Originally posted by Gregg Bolinger:
I am not clear on why you state that you have to validate all fields or none at all. I have several forms with dozens of fields on each form. Some are validated on submit, some are not and all with the standard validation components. Can you clarify what you mean?
I'll try to explain what I mean for "validate all fields or none at all".
Imagine you have a web application with a simple page with a simple input form;
in this form you have some UIInput components to take user input, value bounded to a backing-bean;
some of these components are required and each component may or may not use a converter and one or more validators.
On this form you have one UICommand component (for example a commandButton or commandLink) to save the form and one other to cancel and navigate to another page.
In such a simple, monolithic form, with very limited user interaction, you could feel good with JSF simple approach to convertion/validation an model update. Infact, you can use a commandButton with immediate="false" for the save button and a commandButton with immediate="true" for the cancel button.
But imagine you need a more sophisticated user interaction during form input; for example, you may have two or more UISelectOne component that dynamically submit the form to enable or render other components or to update other components state (for example to fill other UISelectOne components).
You certanly need to use some sort of "immediate" and getSubmittedValue() trick to read values from the interactive portion of the page the user is editing because you don't want to trigger other components convertion and/or validation errors and you may need to manually convert and/or validate these components values you want to read. Moreover, if you decide to use immediate="true" / onchange="this.form.submit()" / valueChangeListener combination on more than one component (for example on two UISelectOne) and these components are required (and initially blank) you cannot change the value of one these without throwing a validation error on the other one.
All these problems derives from the impossibility of selecting components to apply process validations and process updates lifecycle phases during a form submit. This can be obtained using a commandButton with a validationList attribute (and, of course, with a javascript version of this somple mechanism in the case of javascript form submission) as reported in my previous example.