background image

Getting the Attribute Values

<< Creating the Component Tag Handler | Setting Component Property Values >>
<< Creating the Component Tag Handler | Setting Component Property Values >>

Getting the Attribute Values

Retrieving the Component Type
As explained earlier, the first thing MapTag does is to retrieve the type of the component. It does
this by using the getComponentType operation:
public String getComponentType() {
return (
"DemoMap");
}
The value returned from getComponentType must match the value configured for the
component with the component-type element of the application's application configuration
resource file.
"Registering a Custom Component" on page 457
explains how to configure a
component.
Setting Component Property Values
After retrieving the type of the component, the tag handler sets the component's property values
to those supplied as tag attributes values in the page. This section assumes that your component
properties are enabled to accept expressions, as explained in
"Enabling Component Properties
to Accept Expressions" on page 424
.
Getting the Attribute Values
Before setting the values in the component class, the MapTag handler first gets the attribute
values from the page by means of JavaBeans component properties that correspond to the
attributes. The following code shows the property used to access the value of the immediate
attribute.
private javax.el.ValueExpression immediate = null;
public void setImmediate(javax.el.ValueExpression immediate)
{
this.immediate = immediate;
}
As this code shows, the setImmediate method takes a ValueExpression object. This means
that the immediate attribute of the map tag accepts value expressions.
Similarly, the setActionListener and setAction methods take MethodExpression objects,
which means that these attributes accept method expressions. The following code shows the
properties used to access the values of the actionListener and the action attributes
private javax.el.MethodExpression actionListener = null;
public void setActionListener(
Creating the Component Tag Handler
Chapter 13 · Creating Custom UI Components
431