Question

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 scope (view, request, etc)?

Was it helpful?

Solution

It's main usage is as follows:

  • you submit a form
  • it is handled by an action method in a managed bean
  • then a redirecting navigation rule is returned
  • you need to show an object obtained in the action method on the result page

If it weren't for the flash scope, you would either need to pass the result in a serialized form in the URL, or use forward rather than redirect. But this is bad user experience (if he presses refresh)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top