Java Reference
In-Depth Information
D Renders links and display text
<html:link styleClass="ZLink"
<c:out value="${}"/>
The <c:set> tags are initially used to expose our Category object and pro-
ductList to the page scope. Once these objects are exposed to the page, they are
available for the other tags that need them. The list of products and the category
will be used by the JSTL core tags and the Struts <html> tags to accomplish
the display of these objects. The <c:out> tag is used to display the name property of
our Category object. The <c:forEach> tag is used to iterate over the list of prod-
ucts and expose each product in the list to its body, <html:link> is then able to
use the exposed product and create a link to the page that views the product.
Within the body of the <html:link> tag we use the <c:out> tag to render the value
of the product name.
The Struts tags use a common nomenclature for working with objects. The
name attribute is the key that points to the object which is exposed in a scope. For
example, suppose you expose an object to the page using the name category .
category is what the name attribute should refer to. A corresponding attribute to
the name attribute is the property attribute, which gives the tag access to a particu-
lar property of the named object.
In contrast, the JSTL tags have an EL (Expression Language) that is more
robust than the name and property attributes of the Struts tags. The EL is used to
expose objects in a scope to a particular JSTL attribute. We will not discuss EL in
detail here, but if you want to learn more we recommend Shawn Bayern's JSTL in
Action (Manning, 2002).
After coding all of the necessary components, we can now add an action map-
ping to our struts-config.xml (see listing 14.11) so that our application can use
those components. We first specify our CatalogBean as a form bean by assigning
the name catalogBean and providing a type of our fully qualified class name for
the CatalogBean . We now have a form bean that our action mapping can take
advantage of.
Search WWH ::

Custom Search