Visionwebhosting Struts Website Hosting - Jakarta Struts Web Hosting Guide
,ch14.9433 Page 468 Monday, February 14, 2005 12:55 PM
Example 14 23. Logon page using Struts Faces components (continued)
If you've never used JavaServer Faces, this page probably looks funky. The page
starts conventionally and declares the
directives for the JSF core and html tag
libraries, as well as the Struts Faces tag library.
To prevent collision with the JSTL core tag library, the taglib declara
tion for the JSF core tag library commonly uses f instead of c as the
prefix. You can think of f as standing for faces or framework.
On this page, the
tag contains the entire content of the view. All JSF pages
must contain a
tag that encapsulates the custom JSF tags. The
from the Struts Faces library, creates an HTML form that can be submitted to a
Struts action. The
tags display label text for input fields declared with
tag creates a password input field. The
tag creates the form's submit button.
When this page was first written, yours truly inadvertently left off the
tags. As Struts developers, the best practice is
to eschew specifying the
attribute for tags like
since the values are
automatically retrieved from the form based on name. When this application was
tested, data entered on the form wasn't populated to the action form. Because Jav
aServer Faces uses a different binding convention than Struts, you must explicitly
bind each field to a form bean property. Adding the
attributes to the form as
shown solved the problem.
The Struts Faces tags resemble the Struts html tag library. By design, Struts develop
ers will find it easy to learn the Struts Faces tags. The
tag, for example, closely
matches the Struts
tag. However, with the
tag, you use the JSF html
tags instead of the Struts html tags. Table 14 2 provides a complete list of tags
included with Struts Faces.
Table 14 2. Struts Faces tags
element, similar to the Struts
Creates a hyperlink that can be used to submit a form
Displays accumulated action errors, similar to the Struts
Creates an HTML form that submits to a Struts action, similar to the Struts
468 | Chapter 14: Tiles and Other Presentation Approaches
This is the Title of the Book, eMatter Edition
Copyright 2005 O'Reilly & Associates, Inc. All rights reserved.