bakoyaro
bakoyaro

Reputation: 2558

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

Upvotes: 4

Views: 1419

Answers (1)

Bozho
Bozho

Reputation: 597076

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)

Upvotes: 4

Related Questions