For managed beans, the JSF 2.0 specification includes the standard scopes (request, session, and application) and also includes a new scope - View - which is maintained for each unique view in the session. Multiple Ajax-based requests can occur during the lifespan of a view. This scope eliminates the need for extended request scope as implemented in the ICEfaces 1.x vintage framework. ICEfaces 2.0 naturally inherits the new JSF 2.0 view scope.
The Window scope is an extended scope provided by the ICEfaces framework that acts much like View scope, but survives a page refresh. Under View scope a refresh results in the disposal of the current view and the creation of a new one, thus all view-scoped state is reset. ICEfaces provides a Window scope to help handle many use cases where the resetting of state on a page refresh may be undesirable. Under Window scope, if a view is disposed of, window-scoped state is held for a short configurable timeout period (typically a fraction of a second). If a GET occurs on the same view within the timeout duration, it is assumed to be a refresh of the current browser window and window-scoped state is maintained and associated with the new view. If the timeout expires, then the window-scoped state is disposed.
You can indicate that a managed bean should be in Window scope by marking it with the @CustomScope annotation and specifying an expression language binding to the "window" map:
A bean can also be marked for Window scope in a faces-config.xml file by specifying the custom map:
There are other useful annotations related to the use of window-scoped beans.
The standard @PostConstruct and @PreDestroy annotations that can be applied to managed beans in other scopes can also be applied to managed beans in Window scope:
ICEfaces also provides other custom annotations which can be used in conjunction with window-scoped beans.
The @AllWindowsClosed method annotation can be used on session scoped beans for helping to clean up resources when all the windows for a particular session have been closed.
The @WindowDisposed annotation is used for more efficient clean up of view-scoped beans.
More information is provided on these and other custom annotations in the Annotations section of the documentation.
© Copyright 2018 ICEsoft Technologies Canada Corp.