I'm looking at http://issues.apache.org/jira/browse/TOMAHAWK-169 ( add
message attribute to all validators ) and I'm thinking the best way to
approach this is to create a ValidatorBase class that all tomahawk and
sandbox components would inherit from. This class would provide a
copy of the following UIComponentBase methods so the same attribute
handling could be done within validators that we do with components.
public ValueBinding getValueBinding(String name)
public void setValueBinding(String name, ValueBinding binding)
protected FacesContext getFacesContext()
For example,
public String getMessage() {
if (_message != null) return _message;
ValueBinding vb = getValueBinding("message");
return vb != null ?
_ComponentUtils.getStringValue(getFacesContext(), vb) : null;
}
ValidatorBase would also implement the message attribute, although
it'll be up to the individual validator to use getMessage() to use the
value.
Eventually, I see this class (and the related ValidatorBaseTag class)
as being put into the commons api code so that other third-party
validators could build from it, but that's another discussion.
So far, this "common validator code" is already present in
EqualsValidator and CompareToValidator.
There will likely be other common validator methods that we'll add as
time goes by.