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
4
votes
0 answers

Are Errors still present in JSF Mojarra 2.2.5 with flash scope?

Still getting this error with last Mojarra 2.2.5 version when i tried to get back my flash parameters. 29 janv. 2014 08:24:22 com.sun.faces.context.flash.ELFlash getCurrentFlashManager GRAVE: JSF1094: Could not decode flash data from incoming cookie…
ZheFrench
  • 1,164
  • 3
  • 22
  • 46
4
votes
2 answers

Disable oam.Flash.RENDERMAP.TOKEN

I am using Apache MyFaces 2.0. I notice that a cookie oam.Flash.RENDERMAP.TOKEN is getting created for each view, even though I am not using Flash scope and I have set org.apache.myfaces.DISABLE_FLASH_SCOPE=true. How can I remove the…
ad-inf
  • 1,520
  • 4
  • 30
  • 53
3
votes
1 answer

After post is setting a value in JSF2 flash scope, it is visible again on second GET request to a page (Flash scope considered harmful)

I tested new Flash scope in JSF2 but I found a major issue with it or I am lacking some knowledge. Having a page: Value in flash: #{flash.text}
Krzysiek
  • 31
  • 3
3
votes
1 answer

Does NavigationHandler.handleNavigation() clear the flash?

I am using JSF2.0 Mojarra 2.0.2. I have a method that logs out a user and puts a logout message in the flash, forwards to the login page (which has a div that prints out the flash). However, when I use navigationHandlers handleNavigation method for…
kgrad
  • 4,672
  • 7
  • 36
  • 57
3
votes
2 answers

Flash messages not shown after redirect in MyFaces while it worked in Mojarra

I've my own ExceptionHandlerWrapper to manage ViewExpiredException and other errors. The idea is to catch the error, add some error message and redirect (with a redirection, not navigation) to the index page, where the error message will be…
cocorossello
  • 1,289
  • 1
  • 17
  • 30
3
votes
0 answers

The response was already committed by the time we tried to set the outgoing cookie for the flash. Any values stored to the flash will not be available

I have one view scoped JSF managed bean. In the action listener method of in this managed bean, I'm redirecting to another page as follows. public void register() { ExternalContext context =…
Tiny
  • 27,221
  • 105
  • 339
  • 599
2
votes
1 answer

Play Framework flash variable adding commas to form data

I'm validating a form in Play framework(java), and it is adding commas to my form values after submission. Here's the form: #{form @doCreate()}
Indigenuity
  • 9,332
  • 6
  • 39
  • 68
2
votes
1 answer

Why is flash.keep() removing the key if it is in a bean but not in EL in Facelets page?

So I have this very small JSF example: Index
Koray Tugay
  • 22,894
  • 45
  • 188
  • 319
2
votes
1 answer

Flash scope warning and Flash not delete after redirect

I'm trying to pass an object while redirecting between View1 to View2, using JSF and Primefaces. I'm using JSF Flash scope to do so,The object do pass to the second view but I'm still getting this warnning: com.sun.faces.context.flash.ELFlash…
2
votes
1 answer

flash.keep & flash.setKeepMessages(true) on redirection

I am going through an example in Anghel Leonard book Mastering Java Server Faces 2.2. The author demonstrates with an example on how preserve data for the next request on redirection when the bean is made is @RequestScoped. This is the code for…
Farhan stands with Palestine
  • 13,890
  • 13
  • 58
  • 105
2
votes
0 answers

How to keep JSF flash scope parameters after an ajax request on the page?

I am able to keep the flash variable for a page reload with the FacesContext.getCurrentInstance().getExternalContext().getFlash().keep("someVar"); But any postback to the page cause me to lose the flash variable. I've tried putting on a…
BudgieA
  • 21
  • 3
2
votes
1 answer

Can the Flash data be persisted after redirection?

Using JSF 2.1.29 In list.xhtml
mehere
  • 1,487
  • 5
  • 28
  • 50
2
votes
2 answers

Java equivalent of C#'s HttpContext.Current.Items.set/get

I am attempting to translate the functionality of a C# API, and I have arrived at some code that I cannot find a confident solution for. It concerns storing data in the correct web-contexted scope. For now I could have fixed the issue simply by…
jumps4fun
  • 3,994
  • 10
  • 50
  • 96
2
votes
0 answers

Grails - flash goes out of scope when forcing https

I'm using Spring Security Core and grails.plugins.springsecurity.secureChannel.definition to enforce certain areas of a website to use https. Because it works by redirecting the page from an insecure page to a secure one, it has the side effect of…
Anonymous1
  • 3,877
  • 3
  • 28
  • 42
2
votes
1 answer

flash message not displaying after redirect from f:phaselistener

I have an issue with understanding how flash works in the jsf lifecycle. I am trying to redirect to a different page from a phase listener through a normal get request and at the same time adding a flash message(of course i have set the…
shorley
  • 35
  • 1
  • 5