ClayContext clayContext = (ClayContext) context;
if (clayContext == null) {
throw new NullPointerException(getMessages().getMessage("clay.null.clayContext"));
}
AttributeBean attributeBean = clayContext.getAttribute();
if (attributeBean == null) {
throw new NullPointerException(getMessages().getMessage("clay.null.attributeBean"));
}
Object child = clayContext.getChild();
if (child == null) {
throw new NullPointerException(getMessages().getMessage("clay.null.childComponent"));
}
ComponentBean displayElement = clayContext.getDisplayElement();
if (displayElement == null) {
throw new NullPointerException(getMessages().getMessage("clay.null.componentBean"));
}
FacesContext facesContext = clayContext.getFacesContext();
if (facesContext == null) {
throw new NullPointerException(getMessages().getMessage("clay.null.facesContext"));
}
// don't try to set the binding attribute of anything but a component
if (attributeBean.getName().equals("binding")
&& !(child instanceof UIComponent)) {
return isFinal;
}
// skip trying to set the converterId on a converter
if (attributeBean.getName().equals("converterId")
&& child instanceof Converter) {
return isFinal;
}
// replace all symbols returning the target attribute value
String expr = replaceMnemonic(clayContext);
//exit if null or empty string
if (expr == null) {
return isFinal;
}
String bindingType = attributeBean.getBindingType();
if (bindingType == null) {
bindingType = AttributeBean.BINDING_TYPE_NONE;
}
//contains expression language
boolean isEL = isValueReference(expr);
//use value binding
boolean isVB = ((bindingType.equals(AttributeBean.BINDING_TYPE_VALUE))
&& (child instanceof UIComponent));
//use early binding
boolean isEarly = bindingType.equals(AttributeBean.BINDING_TYPE_EARLY);
if (isEL && isVB) {
getTagUtils().setValueBinding((UIComponent) child, attributeBean.getName(), expr);
} else if (isEL && isEarly) {
ValueBinding vb = facesContext.getApplication().createValueBinding(expr);
Object value = vb.getValue(facesContext);
try {
setProperty(facesContext, child, attributeBean.getName(), value);
} catch (Exception e) {
if (child instanceof UIComponent) {
((UIComponent) child).getAttributes().put(attributeBean.getName(), expr);
} else {
throw e;
}
}
} else {
try {
setProperty(facesContext, child, attributeBean.getName(), expr);
} catch (Exception e) {
if (child instanceof UIComponent) {
((UIComponent) child).getAttributes().put(attributeBean.getName(), expr);
} else {
if (child.getClass().getName().equals("org.apache.shale.validator.CommonsValidator")) {
Map vars = (Map) propertyHelper.getValue(child, "vars");
//vars collection is like the components attributes
//native support for shale components
vars.put(attributeBean.getName(), expr);
} else {
throw e;
}
}
}