public void applyAttachedObject(FacesContext context, UIComponent parent) {
if (!(parent instanceof ActionSource)) {
throw new TagException(this.tag, "Parent is not of type ActionSource, type is: " + parent);
}
ActionSource as = (ActionSource) parent;
FaceletContext ctx = (FaceletContext) context.getAttributes().get(TagHandlerUtils.FACELET_CONTEXT_KEY);
if (this.listenerMethod != null) {
MethodExpression listenerMethodExpression = this.listenerMethod.getMethodExpression(ctx, Void.TYPE,
new Class<?>[] { ActionEvent.class });
as.addActionListener(new MethodExpressionActionListener(listenerMethodExpression));
} else {
ValueExpression b = null;
if (this.binding != null) {
b = this.binding.getValueExpression(ctx, ActionListener.class);
}
ActionListener listener = new LazyActionListener(this.listenerType, b);
as.addActionListener(listener);
}
}