Questions tagged [flash-scope]

The flash scope is a scope which lives during the redirected request only. This is particularly useful if you want to prepare a request scoped object in the server side before redirecting. The object is then available in the redirected request.

The flash scope is originally a Ruby on Rails invention. It's later been taken over in several other modern web based MVC frameworks like JSF2, Play!, etcetera.

The flash scope is backed by a short living cookie which is associated with a data entry in the session scope. Before the redirect, a cookie will be set on the HTTP response with a value which is uniquely associated with the data entry in the session scope. After the redirect, the presence of the flash scope cookie will be checked and the data entry associated with the cookie will be removed from the session scope and be put in the request scope of the redirected request. Finally the cookie will be removed from the HTTP response. This way the redirected request has access to request scoped data which was been prepared in the initial request.

The flash scope is often used for messaging purposes in case of form submits following the Post-Redirect-GET pattern. As a redirect basically instructs the browser to create a brand new HTTP request, it would not be possible to use the request scope to pass request based data from the controller to the view. The flash scope solves exactly this problem.

53 questions
32
votes
2 answers

Understand Flash Scope in JSF2

From what I understand , objects placed inside the Flash scope in a faces request lifecycle will be available for the next faces request lifecycle and then clear. Suppose I have two pages: page01.xhtml:
Ken Chan
  • 84,777
  • 26
  • 143
  • 172
18
votes
4 answers

Getting warning from JSF: The response was already committed by the time we tried to set the outgoing cookie for the flash

I have a page1.jsf, in this page i have a commandButton that put an object in ELFlash, and redirects to page2.jsf. In this page i recover the object by ELFlash. Everything works fine. But while the user remains in page2.jsf, for every ajax request,…
Mateus Viccari
  • 7,389
  • 14
  • 65
  • 101
13
votes
1 answer

How do I retrieve the FacesContext within a Filter

How do I retrieve the FacesContext within a Filter? I followed following article on how to retrieve the FacesContext in a Filter: http://ocpsoft.org/java/jsf-java/jsf-20-extension-development-accessing-facescontext-in-a-filter/ But the problem is…
djmj
  • 5,579
  • 5
  • 54
  • 92
12
votes
3 answers

Exception about flash in Mojarra JSF

I upgraded to Mojarra JSF 2.2.1 (from 2.1.22) and since then for each of my requests I'm having an exception in console: GRAVE: JSF1094: Could not decode flash data from incoming cookie value /?. Processing will continue, but the flash is…
Aritz
  • 30,971
  • 16
  • 136
  • 217
11
votes
2 answers

Object in Flash scope is not available after redirect

I have a misunderstanding with the use of flash scope in jsf 2. I want to put an object in flash map during my action and show this object in the next page. Here is my action (call by h:commandLink): public String showDetail(PersonneDTO personne) { …
Kiva
  • 9,193
  • 17
  • 62
  • 94
9
votes
3 answers

Removing JSF messages from the flash

I have one page that does something and when the user clicks a button, the user is redirected to another page and a message is displayed. Here is my code: public String confirm() { FacesContext context = FacesContext.getCurrentInstance(); …
egbokul
  • 3,944
  • 7
  • 36
  • 54
9
votes
1 answer

How to keep JSF flash scope parameters on page reload?

I use flash scope to pass a setting object between @viewscoped contollers. But if I make a page reload on one of them, then the flash map is empty and the setting object is not initialized. Is it possible to keep flash scope on page reload? My…
Alex
  • 111
  • 1
  • 1
  • 3
8
votes
1 answer

Is Flash scope free of race conditions?

I found out that the JSF 2.0 Flash scope is implemented in Mojarra 2.x via a cookie. What seems to happen is that when navigating from view A to view B using The Flash, JSF sends a redirect response. It is this same response that contains the…
Mike Braun
  • 3,729
  • 17
  • 15
7
votes
3 answers

java.lang.NullPointerException at com.sun.faces.context.flash.ELFlash.loggingGetPhaseMapForReading

I am running my application in apache-tomcat-7.0.16 using JSF-2.1.2. After adding navigation rules in faces-config.xml, I am getting the NullPointerException. This bug was filed in JSF forum. Is there any compatible version between JSF and the…
Gnanam
  • 513
  • 2
  • 10
  • 21
6
votes
2 answers

Send flash message to redirected page

I have one page where I add new item when I save data I go to other page where I want to see message that "Data was saved successful". I read that message belong to request scope that's why I am using the flash…
Ray
  • 1,788
  • 7
  • 55
  • 92
5
votes
1 answer

JSF Flash Scope remembers too many messages

I have a simple flow in my appliaction - if you fill out and press save on one form (if everything goes well) you are redirected to a second view with a list. Now I wanted to add a message saying "You successfuly added an object" but since I'm using…
Mateusz Dymczyk
  • 14,969
  • 10
  • 59
  • 94
5
votes
0 answers

Deploying Grails 3 App throws FlashScope Exception

When deploying a new version of a Grails 3.1.1 application war into a running Tomcat, I am presented with an exception when accessing it after deployment. Oct 13, 2016 11:39:58 AM org.apache.catalina.core.StandardWrapperValve invoke SEVERE:…
Cyntech
  • 5,362
  • 6
  • 33
  • 47
4
votes
1 answer

Spring MVC FlashMap and RedirectAttributes request mapping

Yesterday I downloaded the new Spring 3.1RC to test the just introduced support for flash scoped variables in Spring MVC. Unfortunately I could not make it working... I have a HTML form containing some checkboxes without spring:forms tags. Something…
Ciaccia
  • 382
  • 3
  • 14
4
votes
1 answer

What are some uses for the "flash" scope in JSF?

I'm in the process of learning JSF 2.1, and the "flash" scope seems to overlap other scopes. Does this bring any value, or should I disregard it as a modern GOTO: statement? Does it have a higher usage? Is it preferable to use over other types of…
bakoyaro
  • 2,550
  • 3
  • 36
  • 63
4
votes
1 answer

How to resolve JSF1095 Flash Warning "Response already committed" in f:selectItems component?

I meet a strange behavior with JSF 2.4 on Mojarra. I'm using flash parameters to pass from a page to another. Each time i arrive on a new page, i retrieve my flash parameters in Postconstruct annoted method. Then if the page is refreshed, the user…
ZheFrench
  • 1,164
  • 3
  • 22
  • 46
1
2 3 4