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"));
}
ActionSource parent = (ActionSource) clayContext.getParent();
if (parent == null) {
throw new NullPointerException(getMessages()
.getMessage("clay.null.parentComponent"));
}
FacesContext facesContext = clayContext.getFacesContext();
if (facesContext == null) {
throw new NullPointerException(getMessages()
.getMessage("clay.null.facesContext"));
}
ActionListener listener = null;
try {
AttributeBean attr = displayElement.getAttribute("binding");
if (attr != null && isValueReference(attr.getValue())) {
clayContext.setAttribute(attr);
String expr = replaceMnemonic(clayContext);
ValueBinding vb = facesContext.getApplication().createValueBinding(expr);
listener = (ActionListener) vb.getValue(facesContext);
} else {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
if (loader == null) {
loader = getClass().getClassLoader();
}
listener = (ActionListener) loader.loadClass(
displayElement.getComponentType()).newInstance();
loader = null;
}
} catch (Exception e) {
log.error(getMessages().getMessage("create.actionListener.error",