if (expressionString != null) {
ExpressionFactory expressionFactory = faceletContext.getExpressionFactory();
MethodExpression action = new TagMethodExpression(value, expressionFactory.createMethodExpression(
faceletContext, expressionString, String.class, ComponentUtils.ACTION_ARGS));
// TODO jsf 1.2
((ActionSource) parent).setAction(new LegacyMethodBinding(action));
}
} else if ("actionListener".equals(mode.getValue())) {
String expressionString = value.getValue();
while (isSimpleExpression(expressionString)) {
if (isMethodOrValueExpression(expressionString)) {
ValueExpression expression
= faceletContext.getVariableMapper().resolveVariable(removeElParenthesis(expressionString));
if (expression == null) {
if (LOG.isDebugEnabled()) {
// when the action hasn't been set while using a composition.
LOG.debug("Variable can't be resolved: value='" + expressionString + "'");
}
expressionString = null;
break;
} else {
expressionString = expression.getExpressionString();
}
} else {
LOG.warn("Only expressions are supported mode=actionListener value='" + expressionString + "'");
expressionString = null;
break;
}
}
if (expressionString != null) {
ExpressionFactory expressionFactory = faceletContext.getExpressionFactory();
MethodExpression actionListener = new TagMethodExpression(value, expressionFactory.createMethodExpression(
faceletContext, expressionString, null, ComponentUtils.ACTION_LISTENER_ARGS));
// TODO jsf 1.2
((ActionSource) parent).setActionListener(new LegacyMethodBinding(actionListener));
}
} else if ("actionFromValue".equals(mode.getValue())) {
if (!value.isLiteral()) {
String result = value.getValue(faceletContext);
parent.getAttributes().put(name.getValue(), new ConstantMethodBinding(result));
}
} else if ("valueIfSet".equals(mode.getValue())) {
String expressionString = value.getValue();
while (isSimpleExpression(expressionString)) {
if (isMethodOrValueExpression(expressionString)) {
ValueExpression expression
= faceletContext.getVariableMapper().resolveVariable(removeElParenthesis(expressionString));
if (expression == null) {
if (LOG.isDebugEnabled()) {
// when the action hasn't been set while using a composition.
LOG.debug("Variable can't be resolved: value='" + expressionString + "'");
}
expressionString = null;
break;
} else {
expressionString = expression.getExpressionString();
}
} else {
LOG.warn("Only expressions are supported mode=actionListener value='" + expressionString + "'");
expressionString = null;
break;
}
}
if (expressionString != null) {
ValueExpression expression = value.getValueExpression(faceletContext, Object.class);
ELAdaptor.setExpression(parent, name.getValue(faceletContext), expression);
}
} else {
throw new FacesException("Type " + mode + " not suppored");
}
} else {
String nameValue = name.getValue(faceletContext);
if (Attributes.RENDERED.equals(nameValue)) {
if (value.isLiteral()) {
parent.setRendered(value.getBoolean(faceletContext));
} else {
ELAdaptor.setExpression(parent, nameValue, value.getValueExpression(faceletContext, Boolean.class));
}
} else if (Attributes.RENDERED_PARTIALLY.equals(nameValue)
&& parent instanceof SupportsRenderedPartially) {
if (value.isLiteral()) {
String[] components = ComponentUtils.splitList(value.getValue());
((SupportsRenderedPartially) parent).setRenderedPartially(components);
} else {
ELAdaptor.setExpression(parent, nameValue, value.getValueExpression(faceletContext, Object.class));
}
} else if (Attributes.STYLE_CLASS.equals(nameValue)) {
// TODO expression
ComponentUtils.setStyleClasses(parent, value.getValue());
} else if (Attributes.MARKUP.equals(nameValue)) {
if (parent instanceof SupportsMarkup) {
if (value.isLiteral()) {
ComponentUtils.setMarkup(parent, value.getValue());
} else {
ValueExpression expression = value.getValueExpression(faceletContext, Object.class);
ELAdaptor.setExpression(parent, nameValue, expression);
}
} else {
LOG.error("Component is not instanceof SupportsMarkup. Instance is: " + parent.getClass().getName());
}
} else if (parent instanceof EditableValueHolder && Attributes.VALIDATOR.equals(nameValue)) {
MethodExpression methodExpression = getMethodExpression(faceletContext, null, ComponentUtils.VALIDATOR_ARGS);
if (methodExpression != null) {
// TODO jsf 1.2
((EditableValueHolder) parent).setValidator(new LegacyMethodBinding(methodExpression));
}
} else if (parent instanceof EditableValueHolder
&& Attributes.VALUE_CHANGE_LISTENER.equals(nameValue)) {
MethodExpression methodExpression =
getMethodExpression(faceletContext, null, ComponentUtils.VALUE_CHANGE_LISTENER_ARGS);
if (methodExpression != null) {
// TODO jsf 1.2
((EditableValueHolder) parent).setValueChangeListener(new LegacyMethodBinding(methodExpression));
}
} else if (parent instanceof ValueHolder && Attributes.CONVERTER.equals(nameValue)) {
setConverter(faceletContext, parent, nameValue);
} else if (parent instanceof ActionSource && Attributes.ACTION.equals(nameValue)) {
MethodExpression action = getMethodExpression(faceletContext, String.class, ComponentUtils.ACTION_ARGS);
if (action != null) {
// TODO jsf 1.2
((ActionSource) parent).setAction(new LegacyMethodBinding(action));
}
} else if (parent instanceof ActionSource && Attributes.ACTION_LISTENER.equals(nameValue)) {
MethodExpression action = getMethodExpression(faceletContext, null, ComponentUtils.ACTION_LISTENER_ARGS);
if (action != null) {
// TODO jsf 1.2
((ActionSource) parent).setActionListener(new LegacyMethodBinding(action));
}
} else if (!parent.getAttributes().containsKey(nameValue)) {
if (value.isLiteral()) {
parent.getAttributes().put(nameValue, value.getValue());
} else {