,ch14.9433  Page 469  Monday, February 14, 2005  12:55 PM
Table 14 2. Struts Faces tags (continued)
Tag name
Description
html
Generates an
 element with optional locale sensitivity, similar to the Struts
html:html
 tag
javascript
Generates the JavaScript for client side validation using the Validator, similar to the Struts
html:
javascript
 tag
loadMessages
Loads messages resources into a map for access by JSF tags such as
h:outputText
message
Displays a localized message, similar to the
bean:message
 tag
stylesheet
Generates a link to a stylesheet
write
Renders a property value from a model object, similar to the
bean:write
 tag
The
FacesRequestProcessor
processes the submitted logon form and executes the
LogonAction
. This action doesn't have to do anything special related to JSF. The
Struts Faces library integrates Struts and JSF so your action classes and action forms
require no modification when using JSF. Example 14 24 shows the
LogonAction
for
this application. A  real  action would authenticate the user.
Example 14 24. Action for logon
package com.oreilly.strutsckbk.ch14;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
public class LogonAction extends Action {
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        String name = (String) PropertyUtils.getSimpleProperty(form, "username");
        User user = new User( );
        user.setUsername(name);
        request.getSession( ).setAttribute("user", user);
        return mapping.findForward("success");
    }
}
The application culminates by rendering a  welcome  page that includes text from
the message resources bundle as well as the username entered on the preceding form.
The welcome.jsp page, accessed through the welcome.faces path, is shown in
Example 14 25.
Example 14 25. Rendering HTML with JSF and Struts Faces tags
<%@ page contentType="text/html;charset=UTF 8" language="java" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
Integrating JavaServer Faces with Struts | 469
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