,ch14.9433  Page 468  Monday, February 14, 2005  12:55 PM
Example 14 23. Logon page using Struts Faces components (continued)
    
             required="true" size="10"/> 

    
  
If you've never used JavaServer Faces, this page probably looks funky. The page
starts conventionally and declares the
taglib
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
f:view
tag contains the entire content of the view. All JSF pages
must contain a
f:view
tag that encapsulates the custom JSF tags. The
s:form
tag,
from the Struts Faces library, creates an HTML form that can be submitted to a
Struts action. The
h:outputLabel
tags display label text for input fields declared with
the
h:inputText
tags. The
h:inputSecret
tag creates a password input field. The
h:
commandButton
 tag creates the form's submit button.
When this page was first written, yours truly inadvertently left off the
value
attribute
for the
h:inputText
and
h:inputSecret
tags. As Struts developers, the best practice is
to eschew specifying the
value
attribute for tags like
html:text
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
value
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
s:form
tag, for example, closely
matches the Struts
html:form
tag. However, with the
s:form
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
Tag name
Description
base
Creates a
 element, similar to the Struts
html:base
 tag
commandLink
Creates a hyperlink that can be used to submit a form
errors
Displays accumulated action errors, similar to the Struts
html:errors
 tag
form
Creates an HTML form that submits to a Struts action, similar to the Struts
html:form
 tag
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.






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

strutsweb hosting

 

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved