The Struts-Faces Integration Library (Version 1.0) README File
$Id: README.txt 400336 2006-05-06 17:02:20Z wsmoak $
============
INTRODUCTION:
============
This package contains an add-on library that supports the use of
JavaServer Faces (JSF) user interface technology in a Struts based web
application, in place of the Struts custom tag libraries.
The Struts-Faces Integration Library should work with any implementation
of JavaServer Faces, version 1.0 or later. It has primarily been tested
against version 1.1 of the JavaServer Faces reference implementation,
available at:
http://java.sun.com/j2ee/javaserverfaces/
========================
NEW AND REVISED FEATURES:
========================
* As of the nightly build 20040902, the URI for the struts-faces tag library
has changed. You should now be using:
<%@ taglib prefix="s" uri="http://struts.apache.org/tags-faces" %>
instead of:
<%@ taglib prefix="s" uri="http://jakarta.apache.org/struts/tags-faces" %>
* It is now possible to mix pure JavaServer Faces pages, and those
using the struts-faces integration library, in the same webapp. Previously,
it was required to use only Struts-based handlers for form submits.
* All attributes of the component tags in the Struts-Faces integration library
have been "value binding enabled", meaning you can use value binding
expressions ("#{...}") to calculate attribute values dynamically.
* It is now possible to use the Struts-Faces Integration Library in conjunction
with application modules using Tiles.
* You may now use a managed bean named "struts" at the beginning of any
value binding expression in order to gain access to request, session, and
application scope objects provided by Struts. See the Javadocs for the
implementation class (org.apache.struts.faces.util.StrutsContext)
for more information about what objects are available.
* You may now use either prefix mapping (/faces/*) or extension mapping
(*.faces) for the JavaServer Faces controller servlet.
* In addition to the <s:message> tag that operates as a direct replacement
for <html:message>, you may also consider using the new <s:loadMessages>
tag that exposes a MessageResources instance as a request attribute
containing a Map. This makes the messages included in the instance
available via value binding expressions (or JSP 2.0 EL expressions).
For example, the logon.jsp page of the example application includes:
...
<s:loadMessages var="messages"/>
...
<h:outputText value="#{messages['logon.header']}"/>
...
to create the header text for the logon form. You may either specify the
application scope key for the MessageResources bunde you want, or omit
the "messages" attribute to load the default MessageResources for the
current application module.
* You can leverage advanced JavaServer Faces features in a Struts based
web application. For example, the converted "Mail Reader" example includes
using the <h:dataTable> for multi-row input as well as output.
* If your Struts application stores a Locale in the session attribute
named Globals.LOCALE_KEY (i.e. using the usual Struts technique for
establishing a user specific locale), this setting will be copied to
the UIViewRoot of the corresponding JSF view, which will therefore
cause it to change the Locale used by JSF components and renderers also.
* New command link component (and associated <s:commandLink> tag that mirrors
the functionality of the standard <h:commandLink> component, but works when
inside a Struts <s:form> component.
This release of the Struts-Faces Integration Library (Version 1.0) has the
following revised features relative to the previous (0.4) release:
* The "focus" attribute on the <s:form> tag should work properly
in all cases now.
* Integration with the Validator Framework should work properly
in all cases now.
=======================================================
USING THE STRUTS-FACES LIBRARY IN YOUR OWN APPLICATIONS:
=======================================================
Using the Struts-Faces integration library in your own Struts-based web
applications is straightforward, and requires the following steps:
* Add the "struts-faces.jar" file from the "lib" subdirectory of this
release into the "/WEB-INF/lib" subdirectory of your webapp.
* Add the following JAR files from the JavaServer Faces reference
implementation's "lib" directory to your application's
"/WEB-INF/lib" directory: jsf-api.jar, jsf-impl.jar,
or install them in your servlet container's shared folder.
(You can also use any other JSF implementation that has
been certified to be compatible with the JSF specification.)
* Add the following JAR files, containing the JSTL release (or
from the JavaServer Faces release) to your application's
"/WEB-INF/lib" directory: jstl.jar, standard.jar, or
install them in your servlet container's shared folder.
* Add the servlet definition for the JavaServer Faces servlet into
your web application's deployment descriptor (/WEB-INF/web.xml):
<servlet>
<servlet-name>faces</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
* If you have a <load-on-startup> element on your declaration of the
Struts controller servlet, modify the value to be "2" or greater
so that FacesServlet is initialized first.
* Add the servlet mapping for the JavaServer Faces servlet into
your web application's deployment descriptor (/WEB-INF/web.xml):
<servlet-mapping>
<servlet-name>faces</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
* The tag library in the Struts-Faces integration library (as well
as those in the JavaServer Faces reference implementation) are
embedded in the JAR files themselves, and rely on the ability of a
Servlet 2.3 (or later) container to automatically recognize them.
Therefore, there is no need to copy the TLD files into the WEB-INF
subdirectory of your web application.
* Modify the JSP pages of your web application to use the JSTL,
JavaServer Faces, and Struts-Faces integration library tags, instead
of the traditional Struts tag libraries. This migration can occur
one page at a time, as you become familiar with the new technologies.
You will want to note the following points in particular:
- Include the following tag library directives at the top of your
page in order to declare them:
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@ taglib prefix="s" uri="http://struts.apache.org/tags-faces" %>
- The Struts-Faces tag library (prefix "s" above) contains replacements
for functionality in the existing Struts HTML tag library that are
not directly provided by JavaServer Faces components. You should
convert your existing use of the Struts HTML variants of these tags
to use the Struts-Faces version instead. (Functionality and attributes
should be basically compatible, so this is usually just a matter of
changing the tag prefixes.)
- In particular, you must use the Struts-Faces version of the
form tag (<s:form>) in order to activate standard Struts features
like automatic creation of the form bean, and looking up the
appropriate action to invoke based on the "action" attribute.
- Replace the use of tags from the Struts HTML library with user interface
component tags provided by the JavaServer Faces reference implementation,
by other third party libraries, or by your application itself. For
example, on the logon.jsp page, the username field was change
评论0