background image

Specifying Where State Is Saved

<< Application Configuration Resource File | Encrypting Client State >>
<< Application Configuration Resource File | Encrypting Client State >>

Specifying Where State Is Saved

8. Repeat steps 1 through 7 for each configuration file.
To specify paths to the files by editing the deployment descriptor directly follow these steps:
1. Add a context-param element to the deployment descriptor.
2. Add a param-value element inside the context-param element and call it
javax.faces.CONFIG_FILES
.
3. Add a param-value element inside the context-param element and give it the path to your
configuration file. For example, the path to the guessNumber application's application
configuration resource file is /WEB-INF/faces-config.xml.
4. Repeat steps 2 and 3 for each application configuration resource file that your application
contains.
Specifying Where State Is Saved
When implementing the state-holder methods (described in
"Saving and Restoring State" on
page 426
), you specify in your deployment descriptor where you want the state to be saved,
either client or server. You do this by setting a context parameter in your deployment
descriptor.
To specify where state is saved using NetBeans IDE, do the following:
1. Expand the node of your project in the Projects pane.
2. Expand the Web Pages and WEB-INF nodes that are under the project node.
3. Double-click web.xml.
4. After the web.xml file appears in the editor pane, click General at the top of the editor pane.
5. Expand the Context Parameters node.
6. Click Add.
7. In the Add Context Parameter dialog:
a. Enter javax.faces.STATE_SAVING_METHOD in the Param Name field.
b. Enter client or server in the Param Value field.
c. Click OK.
To specify where state is saved by editing the deployment descriptor directly follow these steps:
1. Add a context-param element to the deployment descriptor.
2. Add a param-name element inside the context-param element and give it the name
javax.faces.STATE_SAVING_METHOD
.
3. Add a param-value element to the context-param element and give it the value client or
server
, depending on whether you want state saved in the client or the server.
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 client by default. Duke's Bookstore
saves its state in the client.
Basic Requirements of a JavaServer Faces Application
The Java EE 5 Tutorial · September 2007
462