Provide a feature semantically identical to the "flash" concept in Ruby on Rails.
The feature is exposed to users via a custom
ELResolver which introduces a new implicit object,
flash. The flash functions as Map and
can be used in getValue( ) or setValue(
) expressions.
Usage
Consider three JSF views: viewA, viewB, and viewC. The user first views viewA, then clicks a button and is shown viewB, where she clicks a button and is shown viewC. If values are stored into the flash during the rendering or postback phases of viewA, they are available to during the rendering phase of viewB, but are not available during the rendering or postback phases of viewC. In other words, values stored into the flash on "this" request are accessible for the "next" request, but not thereafter.
There are three ways to access the flash.
Using an EL Expression, such as using
#{flash.foo} as the value of an attribute in a JSP
page.
Using the EL API, such as:
FacesContext context = FacesContext.getCurrentInstance();
ValueExpression flashExpression = context.getApplication().
createValueExpression(context.getELContext(), "#{flash.foo}",
null, Object.class);
flashExpression.setValue(context.getELContext(), "Foo's new value");
Using getting the ELFlash directly, such as:
Map<String,Object> flash = ELFlash.getFlash();
flash.put("foo", "Foo's new value");
The main entry point to this feature is the first one. This
library includes a simple custom tag, jsfExt:set, that
evaluates an expression and sets its value into another expression.
jsfExt:set can be used to store values into the flash
from JSP pages, like this:
<jsfExt:set var="#{flash.foo}" value="fooValue"
/>
or this:
<jsfExt:set var="#{flash.keep.bar}" value="#{user.name}"
/>
or even this:
<h:outputText value="#{flash.now.baz}" />
<jsfExt:set var="#{flash.now.baz}" value="#{cookie.userCookie}" />
Related Classes
The complete list of classes that make up this feature is
FlashELResolver
| Modifier and Type | Field and Description |
|---|---|
| private static final String | |
| private static final String | |
| private static final String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Class | getCommonPropertyType(ELContext
The context of this evaluation. context, Object The base object to return the most general property
type for, or base)null to enumerate the set of
top-level variables that this resolver can evaluate.Implements abstract javax. If |
| public Iterator | getFeatureDescriptors(ELContext
The context of this evaluation. elContext, Object The base object whose set of valid properties is to
be enumerated, or base)null to enumerate the set of
top-level variables that this resolver can evaluate.Implements abstract javax. Returns an iterator of |
| public Class | getType(ELContext
The context of this evaluation. elContext, Object The base object whose property value is to be analyzed,
or base, Object null to analyze a top-level variable.The property or variable to return the acceptable
type for. property)Implements abstract javax. Return the valid |
| public Object | getValue(ELContext
The context of this evaluation. elContext, Object The base object whose property value is to be returned,
or base, Object null to resolve a top-level variable.The property or variable to be resolved. property)Implements abstract javax. Hook into the EL resolution process to introduce the
|
| public boolean | isReadOnly(ELContext
The context of this evaluation. elContext, Object The base object whose property value is to be analyzed,
or base, Object null to analyze a top-level variable.The property or variable to return the read-only status
for. property)Implements abstract javax. Returns |
| public void | setValue(ELContext
The context of this evaluation. elContext, Object The base object whose property value is to be set,
or base, Object null to set a top-level variable.The property or variable to be set. property, Object The value to set the property or variable to. value)Implements abstract javax. This method will throw
|
| FLASH_KEEP_VARIABLE_NAME | back to summary |
|---|---|
| private static final String FLASH_KEEP_VARIABLE_NAME | |
| FLASH_NOW_VARIABLE_NAME | back to summary |
|---|---|
| private static final String FLASH_NOW_VARIABLE_NAME | |
| FLASH_VARIABLE_NAME | back to summary |
|---|---|
| private static final String FLASH_VARIABLE_NAME | |
| FlashELResolver | back to summary |
|---|---|
| public FlashELResolver() Not intended for manual invocation. Only called by the JSF Runtime. | |
| getCommonPropertyType | back to summary |
|---|---|
| public Class Implements abstract javax. If
| |
| getFeatureDescriptors | back to summary |
|---|---|
| public Iterator Implements abstract javax. Returns an iterator of
| |
| getType | back to summary |
|---|---|
| public Class Implements abstract javax. Return the valid
| |
| getValue | back to summary |
|---|---|
| public Object getValue(ELContext elContext, Object base, Object property) Implements abstract javax. Hook into the EL resolution process to introduce the
| |
| isReadOnly | back to summary |
|---|---|
| public boolean isReadOnly(ELContext elContext, Object base, Object property) Implements abstract javax. Returns
| |
| setValue | back to summary |
|---|---|
| public void setValue(ELContext elContext, Object base, Object property, Object value) Implements abstract javax. This method will throw
In other words, do not call this method directly to set a value into the flash! The only way to access the flash is either through JSP or via the EL API.
| |