MrCodex
MrCodex

Reputation: 15

Navigation back through history

what's the best practice for navigating back many times (redirecting back)? I created a sessionScoped Bean with a stack but this spoils the navigation in case of having opened different tabs pushing wrong urls.

Navigation Example:

Page A -> Page B -> Page C

Page C -> Page B -> A

How to get the last url and get back and get back again? Ok I implemented viewParams now still don't know to navigate back.

Upvotes: 1

Views: 251

Answers (1)

StuPointerException
StuPointerException

Reputation: 7267

The best model for handling navigation is to rely on the client browser remembering which URLs it has been to; this is the case for all frameworks not just JSF.

JSF makes it easy (and tempting) to maintain a lot of unnecessary state on the session. Keep your session scoped beans as light as possible and make sure that everything that is needed to properly initialise the web beans is encoded in the URL within view parameters. That way you don't have to re-invent the wheel and everything will work without surprises, regardless of how many tabs the client has open.

Upvotes: 1

Related Questions