attributeExpressionString, null, EMPTY_CLASS_ARRAY), attributeNameValueExpression);
// If it is a redirection, a wrapper is used to locate the right instance and call it properly.
if (ccAttrMeRedirection)
{
((ActionSource2)innerComponent).setActionExpression(new ValueExpressionMethodExpression(attributeNameValueExpression));
}
else
{
((ActionSource2)innerComponent).setActionExpression(methodExpression);
}
}
else if ("actionListener".equals(attributeName))
{
//First try to remove any prevous target if any
ActionListener o = (ActionListener) mctx.removeMethodExpressionTargeted(innerComponent, attributeName);
if (o != null)
{
((ActionSource2) innerComponent).removeActionListener(o);
}
// target is ActionSource2
ActionListener actionListener = null;
// If it is a redirection, a wrapper is used to locate the right instance and call it properly.
if (ccAttrMeRedirection)
{
actionListener = new RedirectMethodExpressionValueExpressionActionListener(attributeNameValueExpression);
}
else
{
methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
createMethodExpression(elContext,
attributeExpressionString, Void.TYPE, ACTION_LISTENER_SIGNATURE), attributeNameValueExpression);
methodExpression2 = reWrapMethodExpression(context.getApplication().getExpressionFactory().
createMethodExpression(elContext,
attributeExpressionString, Void.TYPE, EMPTY_CLASS_ARRAY), attributeNameValueExpression);
actionListener = new MethodExpressionActionListener(methodExpression, methodExpression2);
}
((ActionSource2) innerComponent).addActionListener(actionListener);
mctx.addMethodExpressionTargeted(innerComponent, attributeName, actionListener);
}
else if ("validator".equals(attributeName))
{
//First try to remove any prevous target if any
Validator o = (Validator) mctx.removeMethodExpressionTargeted(innerComponent, attributeName);
if (o != null)
{
((EditableValueHolder) innerComponent).removeValidator(o);
}
// target is EditableValueHolder
Validator validator = null;
// If it is a redirection, a wrapper is used to locate the right instance and call it properly.
if (ccAttrMeRedirection)
{
validator = new RedirectMethodExpressionValueExpressionValidator(attributeNameValueExpression);
}
else
{
methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
createMethodExpression(elContext,
attributeExpressionString, Void.TYPE,
VALIDATOR_SIGNATURE), attributeNameValueExpression);
validator = new MethodExpressionValidator(methodExpression);
}
((EditableValueHolder) innerComponent).addValidator(validator);
mctx.addMethodExpressionTargeted(innerComponent, attributeName, validator);
}
else if ("valueChangeListener".equals(attributeName))
{
ValueChangeListener o = (ValueChangeListener) mctx.removeMethodExpressionTargeted(innerComponent, attributeName);
if (o != null)
{
((EditableValueHolder)innerComponent).removeValueChangeListener(o);
}
// target is EditableValueHolder
ValueChangeListener valueChangeListener = null;
// If it is a redirection, a wrapper is used to locate the right instance and call it properly.
if (ccAttrMeRedirection)
{
valueChangeListener = new RedirectMethodExpressionValueExpressionValueChangeListener(attributeNameValueExpression);
}
else
{
methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
createMethodExpression(elContext,
attributeExpressionString, Void.TYPE,
VALUE_CHANGE_LISTENER_SIGNATURE), attributeNameValueExpression);
methodExpression2 = reWrapMethodExpression(context.getApplication().getExpressionFactory().
createMethodExpression(elContext,
attributeExpressionString, Void.TYPE,
EMPTY_CLASS_ARRAY), attributeNameValueExpression);
valueChangeListener = new MethodExpressionValueChangeListener(methodExpression, methodExpression2);
}
((EditableValueHolder) innerComponent).addValueChangeListener(valueChangeListener);
mctx.addMethodExpressionTargeted(innerComponent, attributeName, valueChangeListener);
}
}
}
}
else
{
// composite:attribute targets property only has sense for action, actionListener,
// validator or valueChangeListener. This means we have to retarget the method expression
// to the topLevelComponent.
// Since a MethodExpression has no state, we can use it multiple times without problem, so
// first create it here.
methodSignature = methodSignature.trim();
methodExpression = context.getApplication().getExpressionFactory().
createMethodExpression(elContext,
attributeExpressionString, _getReturnType(methodSignature),
_getParameters(methodSignature));
methodExpression = reWrapMethodExpression(methodExpression, attributeNameValueExpression);
UIComponent topLevelComponentBase = topLevelComponent.getFacet(UIComponent.COMPOSITE_FACET_NAME);
for (String target : targetsArray)
{
UIComponent innerComponent = ComponentSupport.findComponentChildOrFacetFrom(context, topLevelComponentBase, target);
if (innerComponent == null)
{
continue;
}
// If a component is found, that means the expression should be retarget to the
// components related
if (isCompositeComponentRetarget(context, innerComponent, attributeName))
{
innerComponent.getAttributes().put(attributeName, attributeNameValueExpression);
mctx.clearMethodExpressionAttribute(innerComponent, attributeName);
retargetMethodExpressions(context, innerComponent);
}
else
{
//Put the retarget
if (ccAttrMeRedirection)
{
// Since we require here a method expression, it is necessary to wrap the ValueExpression
// into a MethodExpression that handles redirection.
innerComponent.getAttributes().put(attributeName, new ValueExpressionMethodExpression(attributeNameValueExpression));
}
else
{
innerComponent.getAttributes().put(attributeName, methodExpression);
}