if (expressionString != null) {
final ExpressionFactory expressionFactory = faceletContext.getExpressionFactory();
final MethodExpression actionListener
= new TagMethodExpression(value, expressionFactory.createMethodExpression(
faceletContext, expressionString, null, ComponentUtils.ACTION_LISTENER_ARGS));
((ActionSource) parent).addActionListener(new MethodExpressionActionListener(actionListener));
}
} else if ("actionFromValue".equals(mode.getValue())) {
if (!value.isLiteral()) {
final String result = value.getValue(faceletContext);
parent.getAttributes().put(name.getValue(), new ConstantMethodBinding(result));
}
} else if ("valueIfSet".equals(mode.getValue())) {
String expressionString = value.getValue();
String lastExpressionString = null;
while (isMethodOrValueExpression(expressionString) && isSimpleExpression(expressionString)) {
final ValueExpression expression
= faceletContext.getVariableMapper().resolveVariable(removeElParenthesis(expressionString));
if (expression != null) {
lastExpressionString = expressionString;
expressionString = expression.getExpressionString();
} else {
// restore last value
expressionString = lastExpressionString;
break;
}
}
if (expressionString != null) {
final String attributeName = name.getValue(faceletContext);
if (containsMethodOrValueExpression(expressionString)) {
final ValueExpression expression = value.getValueExpression(faceletContext, Object.class);
parent.setValueExpression(attributeName, expression);
} else {
final Object literalValue = getValue(faceletContext, parent, expressionString, attributeName);
parent.getAttributes().put(attributeName, literalValue);
}
}
} else {
throw new FacesException("Type " + mode + " not supported");
}
} else {
final String nameValue = name.getValue(faceletContext);
if (Attributes.RENDERED.equals(nameValue)) {
if (value.isLiteral()) {
parent.setRendered(value.getBoolean(faceletContext));
} else {
parent.setValueExpression(nameValue, value.getValueExpression(faceletContext, Boolean.class));
}
} else if (Attributes.RENDERED_PARTIALLY.equals(nameValue)
&& parent instanceof SupportsRenderedPartially) {
if (value.isLiteral()) {
final String[] components = ComponentUtils.splitList(value.getValue());
((SupportsRenderedPartially) parent).setRenderedPartially(components);
} else {
parent.setValueExpression(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()) {
((SupportsMarkup) parent).setMarkup(Markup.valueOf(value.getValue()));
} else {
final ValueExpression expression = value.getValueExpression(faceletContext, Object.class);
parent.setValueExpression(nameValue, expression);
}
} else {
LOG.error("Component is not instanceof SupportsMarkup. Instance is: " + parent.getClass().getName());
}
} else if (parent instanceof EditableValueHolder && Attributes.VALIDATOR.equals(nameValue)) {
final MethodExpression methodExpression
= getMethodExpression(faceletContext, null, ComponentUtils.VALIDATOR_ARGS);
if (methodExpression != null) {
((EditableValueHolder) parent).addValidator(new MethodExpressionValidator(methodExpression));
}
} else if (parent instanceof EditableValueHolder
&& Attributes.VALUE_CHANGE_LISTENER.equals(nameValue)) {
final MethodExpression methodExpression =
getMethodExpression(faceletContext, null, ComponentUtils.VALUE_CHANGE_LISTENER_ARGS);
if (methodExpression != null) {
((EditableValueHolder) parent).addValueChangeListener(
new MethodExpressionValueChangeListener(methodExpression));
}
} else if (parent instanceof ValueHolder && Attributes.CONVERTER.equals(nameValue)) {
setConverter(faceletContext, parent, nameValue);
} else if (parent instanceof ActionSource && Attributes.ACTION.equals(nameValue)) {
final MethodExpression action = getMethodExpression(faceletContext, String.class, ComponentUtils.ACTION_ARGS);
if (action != null) {
((ActionSource2) parent).setActionExpression(action);
}
} else if (parent instanceof ActionSource && Attributes.ACTION_LISTENER.equals(nameValue)) {
final MethodExpression action
= getMethodExpression(faceletContext, null, ComponentUtils.ACTION_LISTENER_ARGS);
if (action != null) {
((ActionSource) parent).addActionListener(new MethodExpressionActionListener(action));
}
} else if (!parent.getAttributes().containsKey(nameValue)) {
if (value.isLiteral()) {
parent.getAttributes().put(nameValue, value.getValue());
} else {