### Create new RichFaces Documentation Jira issue

Summary
255 characters left
Description
Environment
This will launch the RichFaces Jira page - to complete your feedback please login if needed, and submit the Jira.

JBoss.org Community Documentation

- Prev
- Next

### 6.2.2. < a4j:keepAlive > available since 3.0.0

expand all

#### 6.2.2.1. Description

The <a4j:keepAlive> tag allows to keep a state of a bean between requests.

#### 6.2.2.2. Details of Usage

If a managed bean is declared with request scope in the configuration file with the help of <managed-bean-scope> tag then the life-time of this bean instance is valid only for the current request. Any attempts to make a reference to the bean instance after the request end will throw in Illegal Argument Exception by the server. To avoid these kinds of Exceptions component <a4j:keepAlive> is used to maintain the state of the whole bean object among subsequent request.

Example:

    <a4j:keepAlive beanName = "#{myClass.testBean}"/>

The "beanName" attribute defines the request scope bean name you'd like to re-use. Note that this attribute must point to a legal JSF EL expression which resolves to a managed mean instance. For example for the above code the class definition may look like this one:

    class MyClass{

        ...

        private TestBean testBean;

        // Getters and Setters for testBean.

        ...

    }

The "ajaxOnly" attribute declares whether the value of the bean should be available during a non-Ajax request. If the value of this attribute is "true" a request scope bean keeps the same value during Ajax requests from the given page. If a non-Ajax request is sent from this page the bean is re-created as a regular request scope bean.

#### 6.2.2.3. Reference Data

Table of <a4j:keepAlive> attributes.

Table 6.16. Component Identification Parameters

Name | Value
--- | ---
component-type | org.ajax4jsf.components.KeepAlive
component-family | org.ajax4jsf.components.AjaxKeepAlive
component-class | org.ajax4jsf.components.AjaxKeepAlive

#### 6.2.2.4. Relevant Resources Links

Visit KeepAlive page at RichFaces Livedemo for examples of component usage and their sources.

Search the RichFaces Users forum for some additional information about usage of component.

- Prev6.2.1. < a4j:loadBundle > ...
- Top of page
- Front page
- Next6.2.3. < a4j:loadScript > ...