background image

Setting Component Property Values

<< Getting the Attribute Values | Setting Method Expressions >>
<< Getting the Attribute Values | Setting Method Expressions >>

Setting Component Property Values

javax.el.MethodExpression actionListener) {
this.actionListener = actionListener;
}
private javax.el.MethodExpression action = null;
public void setAction(javax.el.MethodExpression action) {
this.action = action;
}
Setting the Component Property Values
To pass the value of the tag attributes to MapComponent, the tag handler implements the
setProperties
method. The way setProperties passes the attribute values to the component
class depends on whether the values are value expressions or method expressions.
Setting Value Expressions on Component Properties
When the attribute value is a value expression, setProperties first checks if it is not a literal
expression. If the expression is not a literal, setProperties stores the expression into a
collection, from which the component class can retrieve it and resolve it at the appropriate time.
If the expression is a literal, setProperties performs any required type conversion and then
does one of the following:
If the attribute is renderer-independent, meaning that it is defined by the component class,
then setProperties calls the corresponding setter method of the component class.
If the attribute is renderer-dependent, setProperties stores the converted value into the
component's map of generic renderer attributes.
The following piece of the MapTag handler's setProperties method sets the
renderer-dependent property, styleClass, and the renderer-independent property,
immediate
:
if (styleClass != null) {
if (!styleClass.isLiteralText()) {
map.setValueExpression(
"styleClass", styleClass);
} else {
map.getAttributes().put(
"styleClass",
styleClass.getExpressionString());
}
}
...
if (immediate != null) {
if (!immediate.isLiteralText()) {
map.setValueExpression(
"immediate", immediate);
} else {
map.setImmediate(new
Creating the Component Tag Handler
The Java EE 5 Tutorial · September 2007
432