background image

Binding a Component Value to an Implicit Object

<< Binding a Component Value to a Property | Retrieving Values >>
<< Binding a Component Value to a Property | Retrieving Values >>

Binding a Component Value to an Implicit Object

<managed-bean-scope> application </managed-bean-scope>
<managed-property>
<property-name>shape</property-name>
<value>poly</value>
</managed-property>
<managed-property>
<property-name>alt</property-name>
<value>NAmerica</value>
</managed-property>
...
</managed-bean>
This example configures a bean called NA, which has several properties, one of which is called
shape
.
Although the area tags on the chooselocale.jsp page do not bind to an ImageArea property
(they bind to the bean itself), to do this, you refer to the property using a value expression from
the value attribute of the component's tag:
<h:outputText value=
"#{NA.shape}" />
Much of the time you will not include definitions for a managed bean's properties when
configuring it. You need to define a property and its value only when you want the property to
be initialized with a value when the bean is initialized.
If a component tag's value attribute must refer to a property that is not initialized in the
managed-bean
configuration, the part of the value-binding expression after the period must
match the property name as it is defined in the backing bean.
See
"Application Configuration Resource File" on page 437
for information on how to configure
beans in the application configuration resource file.
"Writing Bean Properties" on page 379
explains in more detail how to write the backing bean
properties for each of the component types.
Binding a Component Value to an Implicit Object
One external data source that a value attribute can refer to is an implicit object.
The bookreceipt.jsp page of the Duke's Bookstore application includes a reference to an
implicit object from a parameter substitution tag:
<h:outputFormat title=
"thanks" value="#{bundle.ThankYouParam}">
<f:param value=
"#{sessionScope.name}"/>
</h:outputFormat>
Binding Component Values and Instances to External Data Sources
The Java EE 5 Tutorial · September 2007
366