*/
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
if (component instanceof EditableValueHolder && component.isRendered()) {
Tags tagUtils = new Tags();
EditableValueHolder editableComponent = (EditableValueHolder) component;
// A map that captures information about a component that might contain
// commons validators. The map is organized by a hierarchy "clientId/validatorType/vars"
Map ids = (Map) component.getAttributes().get(VALIDATOR_CLIENTIDS_ATTR);
if (ids == null) {
ids = new TreeMap();
component.getAttributes().put(VALIDATOR_CLIENTIDS_ATTR, ids);
}
// captrue the clientId before renderering
String clientId = component.getClientId(context);
Map validatorVars = (Map) ids.get(clientId);
if (validatorVars == null) {
validatorVars = new TreeMap();
ids.put(clientId, validatorVars);
}
Validator[] validators = editableComponent.getValidators();
// look for components using CommonsValidator
for (int i = 0; i < validators.length; i++) {
if (validators[i] instanceof CommonsValidator) {
CommonsValidator validator = (CommonsValidator) validators[i];
// look for a map of var's by component type
Map localVars = (Map) validatorVars.get(validator.getType());
if (localVars == null) {
localVars = new TreeMap();
validatorVars.put(validator.getType(), localVars);
} else {
localVars.clear();
}
Map vars = validator.getVars();
Iterator vi = vars.entrySet().iterator();
while (vi.hasNext()) {
Map.Entry e = (Map.Entry) vi.next();
// only override if the var contains a value binding expression
if (e.getValue() != null && e.getValue() instanceof String
&& isValueReference((String) e.getValue())) {
localVars.put(e.getKey(), tagUtils.eval((String) e.getValue()));
}
}
}