Forums de discussion

ViewExpired handling

Jan Tošovský, modifié il y a 9 années.

ViewExpired handling

Liferay Master Publications: 566 Date d'inscription: 22/07/10 Publications récentes
Dear All,

I have a dilemma. I plan to implement a new portlet, crucial part of the new portal. I'd like to use JSF as view technology, but to be honest, I am afraid of some JSF caveats like ViewExpired stuff.

http://stackoverflow.com/questions/3642919/javax-faces-application-viewexpiredexception-view-could-not-be-restored

I really do not want my page to be expired (ViewScoped bean) and my app stopped to respond. I do not want to redirect end user to some default or error page. It would look strange if all JSP portlets worked fine, but this one behaved differently.

What are your scenarios in these situations?

Thanks, Jan
thumbnail
Neil Griffin, modifié il y a 9 années.

RE: ViewExpired handling

Liferay Legend Publications: 2655 Date d'inscription: 27/07/05 Publications récentes
Hi Jan,

Do you plan to put your JSF portlet on a public portal page that non-authenticated (Guest) users can visit? Or will the portlet live on a private portal page that can only be reached after a user signs-in?

Kind Regards,

Neil
Jan Tošovský, modifié il y a 9 années.

RE: ViewExpired handling

Liferay Master Publications: 566 Date d'inscription: 22/07/10 Publications récentes
Hi Neil, I am still in the planning stage. The portlet will be available to logged users only. Is there any difference?
thumbnail
Neil Griffin, modifié il y a 9 années.

RE: ViewExpired handling

Liferay Legend Publications: 2655 Date d'inscription: 27/07/05 Publications récentes
Hi Jan,

JSF is normally used by developers as a stateful framework because it provides the benefit of easier development and maintenance.

When JSF is used as a stateful framework, it relies on the session for @ViewScoped managed-beans, @SessionScoped managed-beans, and if the javax.faces.STATE_SAVING_METHOD context-param is "server" (the default), then also the javax.faces.ViewState of the component tree relies on the session.

When a stateful JSF portlet is placed on a private portal page that only authenticated users can access, then the ViewExpiredException you mentioned should not be a problem. The reason why is because Liferay Portal has a client-side timeout that can automatically sign-out an inactive user when the server-side session is about to expire.

But when a stateful JSF portlet is placed on a public portal page that non-authenticated (Guest) users can access, then the ViewExpiredException can occur. Because of this, it is better to use stateless features of JSF for portlets that are placed on a public portal page. This can be done by using "client" for javax.faces.STATE_SAVING_METHOD and @RequestScoped managed-beans. Also with JSF 2.2, there are new features that help with going stateless (such as the stateless views feature). For more information, see Going Stateless with JSF 2.2.

Kind Regards,

Neil
Jan Tošovský, modifié il y a 9 années.

RE: ViewExpired handling

Liferay Master Publications: 566 Date d'inscription: 22/07/10 Publications récentes
Hi Neil,

thanks for a nice overview.

That automatic sign-out could be a straightforward solution for my case, but it is currently disabled (the goal #1 is user convenience). I'll reconsider this.

But I also remember cases where ViewExpiredException has been thrown before session expiration. But it could be caused by some improper caching/redirection.

Jan