10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Retrieving the ComponentType<br />

As explained earlier, the first thing MapTag does is to retrieve the type of the component. It does<br />

this by using the getComponentType operation:<br />

public String getComponentType() {<br />

return ("DemoMap");<br />

}<br />

<strong>The</strong> value returned from getComponentType must match the value configured for the<br />

component with the component-type element of the application’s application configuration<br />

resource file. “Registering a Custom Component” on page 454 explains how to configure a<br />

component.<br />

Setting Component PropertyValues<br />

After retrieving the type of the component, the tag handler sets the component’s property values<br />

to those supplied as tag attributes values in the page. This section assumes that your component<br />

properties are enabled to accept expressions, as explained in “Enabling Component Properties<br />

to Accept Expressions” on page 422.<br />

Getting the AttributeValues<br />

Before setting the values in the component class, the MapTag handler first gets the attribute<br />

values from the page by means of <strong>Java</strong>Beans component properties that correspond to the<br />

attributes. <strong>The</strong> following code shows the property used to access the value of the immediate<br />

attribute.<br />

private javax.el.ValueExpression immediate = null;<br />

public void setImmediate(javax.el.ValueExpression immediate)<br />

{<br />

this.immediate = immediate;<br />

}<br />

As this code shows, the setImmediate method takes a ValueExpression object. This means<br />

that the immediate attribute of the map tag accepts value expressions.<br />

Similarly, the setActionListener and setAction methods take MethodExpression objects,<br />

which means that these attributes accept method expressions. <strong>The</strong> following code shows the<br />

properties used to access the values of the actionListener and the action attributes<br />

private javax.el.MethodExpression actionListener = null;<br />

public void setActionListener(<br />

Creating the ComponentTag Handler<br />

Chapter 13 • Creating Custom UI Components 429

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!