Escolar Documentos
Profissional Documentos
Cultura Documentos
In addition to configuring your application, you must satisfy other requirements of JavaServer Faces applications, including properly packaging all the necessary files and providing a deployment descriptor. This section describes how to perform these administrative tasks. JavaServer Faces applications can be packaged in a WAR file, which must conform to specific requirements to execute across different containers. At a minimum, a WAR file for a JavaServer Faces application must contain the following:
A set of application classes, JavaServer Faces pages, and other required resources, such as image files
An application configuration resource file, which configures application resources A set of tag library descriptor files
For example, a Java Server Faces web application WAR file using Facelets typically has the following directory structure:
$PROJECT_DIR [Web Pages] +- /[xhtml documents] +- /resources +- /WEB-INF +- /classes +- /lib +- /web.xml +- /faces-config.xml (optional) +- /*.taglib.xml (optional) +- /glassfish-web.xml
The the WAR file.
web.xml file (or web deployment descriptor), the set of JAR files, and the set of application files must be contained in the WEB-INF directory of
The servlet used to process JavaServer Faces requests The servlet mapping for the processing servlet
The path to the configuration resource file, if it exists and is not located in a default location
The deployment descriptor can also include other, optional configurations, such as:
Specifying where component state is saved Encrypting state saved on the client
This section gives more details on these configurations. Where appropriate, it also describes how you can make these configurations using NetBeans IDE.
javax.faces.webapp.FacesServlet FacesServlet instance manages the request processing lifecycle for FacesServlet instance in order for the
Before a JavaServer Faces application can launch its first web page, the web container must invoke the application lifecycle process to start. See The Lifecycle of a JavaServer Faces Application for more information.
FacesServlet:
prefix mapping, such as , or an extension mapping, such as . The mapping is used to identify a page as having JavaServer Faces content. Because of this, the URL to the first page of the application must include the URL pattern mapping. The following elements, commonly used in the tutorial examples, specify a prefix mapping:
/faces/*
http://localhost:8080/guessNumber .xhtml extension, the container will send the request to the FacesServlet instance, which will expect a corresponding page of the same name containing the content to exist.
In the case of extension mapping, if a request comes to the server for a page with an
If you are using NetBeans IDE to create your application, a web deployment descriptor is automatically created for you with default configurations. If you created your application without an IDE, you can create a web deployment descriptor.
To specify these paths using NetBeans IDE, do the following. 1. 2. Expand the node of your project in the Projects pane. Expand the Web Pages and WEB-INF nodes that are under the project node. Double-click
3. 4.
5. 6. 7.
After the file appears in the editor pane, click General at the top of the editor pane. Expand the Context Parameters node. Click Add. In the Add Context Parameter dialog:
web.xml. web.xml
a.
b. c. 8.
Type in the Param Name field. Type the path to your configuration file in the Param Value field. Click OK. Repeat steps 1 through 7 for each configuration file.
javax.faces.CONFIG_FILES
3. 4.
5. 6.
After the file appears in the editor pane, click General at the top of the editor pane. Expand the Context Parameters node. In the Add Context Parameter dialog:
web.xml. web.xml
Type
a. b.
c.
javax.faces.STATE_SAVING_METHOD in the Param Name field. Type client or server in the Param Value field.
Click OK.
More Information Implementation of State Saving If state is saved on the client, the state of the entire view is rendered to a hidden field on the page. The JavaServer Faces implementation saves the state on the server by default. Dukes Forest saves its state on the client.
Development. You can also add custom stages according to your requirements.
All web pages are placed at the top level of the WAR file. The
faces-config.xml file and the web.xml file are packaged in the WEB-INF directory. WEB-INF/classes/ directory. WEB-INF/lib/ directory.
All resource files are either under the root of the web application /resources directory, or in the web applications classpath, METAINF/resources/resourceIdentifier directory. For more information on resources, see Web Resources. When packaging your own applications, you can use NetBeans IDE or you can use the build scripts such as those created for Ant. You can modify the build scripts to fit your situation. However, you can continue to package your WAR files by using the directory structure described in this section, because this technique complies with the commonly accepted practice for packaging web applications.