Class FlashELResolver

java.lang.Object
jakarta.el.ELResolver
com.sun.faces.context.flash.FlashELResolver

public class FlashELResolver extends ELResolver

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 Faces 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.

  1. Using an Expression Language Expression, such as using #{flash.foo} as the value of an attribute in a page.
  2. 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");

  3. 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:

<jsfExt:set var="#{flash.now.baz}" value="#{cookie.userCookie}" /> <h:outputText value="#{flash.now.baz}" />

Related Classes

The complete list of classes that make up this feature is