How to get all opened JSF pages, and close or redirect from server side?

714 views Asked by At

We are using Liferay Portal 6.0, and the portlets are Primefaces 3.4, JSF 2.1, We support having more than one browser tab opened for the same user, and each tab can have up to 15 portlets at a time, each portlet is displaying a JSF page (ViewScopedBean) using iframe.

The problem is that the opened JSF pages (inside a iframe inside a portlet) don't know when their portlets get closed or when the whole browser tab gets closed, So they stay in memory until session times out. And this is causing a major problem in server memory leading to complete failure.

My questions are: How can I have the list of opened pages (views) from server side? and how can I also close them? I know that a ViewScopedBean gets destroyed when it is redirected to another page (a dummy page as a workaround), so can I redirect each page from the list (If I can have it!) from server side?

Thank you very much in advance.

1

There are 1 answers

4
AudioBubble On BEST ANSWER

when the whole browser tab gets closed

You can capture a closing tab, with HTML DOM events like beforeunload.

My questions are: How can I have the list of opened pages (views) from server side?

You can list them in an application scoped bean. i.e : Add a view to a list when the view has been called and initiated, and remove it from the list on tab unload/closure ? From that list you can do lot of checkings.. and even close a session if there are no more views associated with it.