My interpretation is that <f:validateRequired> will work only if javax.faces.VALIDATE_EMPTY_FIELDS is set to true OR bean validation is present and javax.faces.VALIDATE_EMPTY_FIELDS is not explicitly set (the second implies the first). Otherwise, this validator is ignored. Perhaps a warning can be issued (in the impl) when the tree is created that this validator has no effect. IMHO, every JSF developer should be enabling this feature, one way or another. The previous behavior was just nonsensical.

The <f:validateRequired> should take precendence over the required attirbute, since the validator is now the prefered approach (actually bean validation is the preferred approach, but when that is absent, the tag is prefered).

So <f:validateRequired> is ignored if VALIDATE_EMPTY_FIELDS is false or absent.

-Dan

On Tue, Oct 20, 2009 at 2:43 PM, Michael Concini <mconcini@gmail.com> wrote:
I'm doing some testing on MyFaces to make sure all is behaving as described in the spec for some of the new tags.  I've run into an issue where I need some clarification on the spec though regarding the validateRequired tag.
The confusion lies in what the interaction and precedence should be for the validateRequired tag vs. the javax.faces.VALIDATE_EMPTY_FIELDS param setting and the algorithm specified for UIInput.validateValue().
The validateValue algorithm says that if javax.faces.VALIDATE_EMPTY_FIELDS has not been set, that we only execute the validators if bean validation is present.  This, however, will prevent the RequiredValidator from executing as well.  Since the javadoc states that adding an f::validateRequired tag has the same affect as setting required="true" on the UIInput, it would seem that at least for this validator, we need to validate empty fields even if bean validation is not present.
What is the proper behavior here?  Should we be ignoring the validateRequired tag unless bean validation is present?  Should we be executing only the RequiredValidator if one is attached?  all validators if a RequiredValidator is attached?  What about if VALIDATE_EMPTY_FIELDS is explicitly set to false?
Any clarification on this would be much appreciated.

Thanks,
Mike




--
Dan Allen
Senior Software Engineer, Red Hat | Author of Seam in Action
Registered Linux User #231597

http://mojavelinux.com
http://mojavelinux.com/seaminaction
http://www.google.com/profiles/dan.j.allen