When the @WindowDisposed annotation is found on a ViewScoped bean, that bean will be removed from the map when the browser window associated with that view is closed.
There are several complexities in the implementation of this feature:
the dispose-window request is handled via a ResourceHandler prior to the JSF lifecycle, therefore the ViewRoot and ViewMap are not yet available (and would not normally be available during the processing of this request; it would exit prior to the JSF lifecycle)
dispose-window may be invoked on windows containing multiple views (such as portlet or JSP inclusion cases)
Ted Goddard
added a comment - There are several complexities in the implementation of this feature:
the dispose-window request is handled via a ResourceHandler prior to the JSF lifecycle, therefore the ViewRoot and ViewMap are not yet available (and would not normally be available during the processing of this request; it would exit prior to the JSF lifecycle)
dispose-window may be invoked on windows containing multiple views (such as portlet or JSP inclusion cases)
Window disposal now triggers a JSF lifecycle for the purpose of gaining access to the View Map. This seems slightly heavyweight, but is not that significant given that all other user events also trigger a JSF lifecycle. No render pass is included in this case.
Ted Goddard
added a comment - Window disposal now triggers a JSF lifecycle for the purpose of gaining access to the View Map. This seems slightly heavyweight, but is not that significant given that all other user events also trigger a JSF lifecycle. No render pass is included in this case.
Initial implementation checked in. Note that this version only supports the Servlet case; for Portlets, it will be necessary to propagate the dispose notification to other contexts.
Ted Goddard
added a comment - Initial implementation checked in. Note that this version only supports the Servlet case; for Portlets, it will be necessary to propagate the dispose notification to other contexts.
We may also want to consider applying @WindowDisposed to beans in other scopes besides View Scope.