Thursday, August 7, 2014

Flash Scope

Flash Scope provides a way to pass objects between various JSF pages or the user views generated by the faces lifecycle. The objects put in Flash scope are available only in the next view and then are cleared out.

In JSF pages you can put or get value from Flash scope in the following ways

1) Put a value in using <c:set>
2) Put a user entered value in flash scope.
This comes in handy when we don't want to map a form field to a backing bean but still want it to make it available in the backing bean or to the next view.
3) Read/Print value from Flash Scope in JSF  ".keep" makes the variable available in the next view as well.

3) Read/Print value from Flash Scope in Backing Bean To keep" flash variables available to next view - fl.setKeepMessages(true);
To put a new object in flash scope - fl.put("Greetings", "Hello")

Download Code