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

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

I have about 3 apps in glassfish-4 using SingleSignOn for security and a 4th app for 'Access Control' where all the users for all the apps login and get redirected to any of the apps the user has access to. Everything has been working perfectly…
0
votes
1 answer

How to transfer secret usernames and passwords between ViewScoped beans?

I am working on a webprojekt where I in order to minimize session bloating are using primarily ViewScoped beans. But then I face the problem that I need to transfer clients usernames and passwords between my beans (to access the database etc.). I…
Kim Jensen
  • 17
  • 4
0
votes
0 answers

In JSF2, could we keep flash parameter more than one redirection on a view?

I'm using Mojara 2.2 ,Tomcat 7 and Pretty Faces 3. I'have a page (called Student) who receives one param from the flash scope. Then when I refresh the page or execute an h:commandButton adding some stuff in my database, the flash param disappears. I…
ZheFrench
  • 1,164
  • 3
  • 22
  • 46
0
votes
1 answer

Is flashmessage the appropiate way to get messages from controller to view?

Suppose a scala play view is supposed to render a range of items if available. If not we want to have a message output instead. It has been suggested to me to get the message from controller to view via "flashmessage" instead of a parameter of the…
Th 00 mÄ s
  • 3,776
  • 1
  • 27
  • 46
0
votes
1 answer

JSF2 and JBoss: Flash scoped messages not surviving post-redirect-get when root virtual host specified

I'm using JBoss EAP 6.1 standalone with JSF 2.1.19 and configured my host as a virtual server at the root context. (Using a non-root context like /myApp, everything works fine). I'm trying to show FacesContext info messages after a redirect using…
Strumbles
  • 406
  • 5
  • 16
0
votes
2 answers

Play2 and Flash Scope, why can't I print my message?

In my current Controller I'm passing a flash message as described in the docs Controller: def test(token: String) = Action { Ok(views.html.mobile.smsReview(smsReviewForm.fill(model), grades, smstoken.get.token)) .flashing("success"…
jakob
  • 5,979
  • 7
  • 64
  • 103
0
votes
1 answer

How can I reach flash scope variables if pages are in different paths? JSF 2.1

Why flash scope variables could not be reachable if view path is different? I have source page: /pages/order/order_view.jsf And target page is in different path: /pages/offer/offer_edit.jsf I have set flash variable after submit on page…
0
votes
1 answer

set Flash.keepMessage to true in JSF 2 configuration file is possible?

This line: FacesContext.getCurrentInstance().getExternalContext().getFlash().setKeepMessages(true); Can be changed by another code in any configuration files? I want to avoid typing this line whenever I need to redirect from code whit this line: …
1 2 3
4