java.lang.Object
org.omnifaces.cdi.viewscope.ViewScopeManager
Manages view scoped bean creation and destroy. The creation is initiated by
ViewScopeContext which is
registered by ViewScopeExtension and the destroy is initiated by ViewScopeEventListener which is
registered in faces-config.xml.
Depending on ViewScoped.saveInViewState(), this view scope manager will delegate the creation and destroy
further to either ViewScopeStorageInSession or ViewScopeStorageInViewState which saves the concrete
bean instances in respectively HTTP session or Faces view state.
- Since:
- 1.6
- Author:
- Radu Creanga <rdcrng@gmail.com>, Bauke Scholtz
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault value of maximum active view scopes in session.static final StringOmniFaces specific context parameter name of maximum active view scopes in session.static final StringMojarra specific context parameter name of maximum number of logical views in session.static final StringMyFaces specific context parameter name of maximum number of views in session. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> TgetBean(Contextual<T> type) Returns the CDI view scoped managed bean from the current Faces view scope, ornullif there is none.<T> TgetBean(Contextual<T> type, CreationalContext<T> context) Returns the CDI view scoped managed bean from the current Faces view scope, and auto-creates one if it doesn't exist.static booleanisUnloadRequest(FacesContext context) Returnstrueif the current request is triggered by an unload request.static booleanisUnloadRequest(HttpServletRequest request) Returnstrueif the given request is triggered by an unload request.voidThis method is invoked during view destroy byViewScopeEventListener, in that case destroy all beans in current active view scope.
-
Field Details
-
PARAM_NAME_MAX_ACTIVE_VIEW_SCOPES
OmniFaces specific context parameter name of maximum active view scopes in session.- See Also:
-
PARAM_NAME_MOJARRA_NUMBER_OF_VIEWS
Mojarra specific context parameter name of maximum number of logical views in session.- See Also:
-
PARAM_NAME_MYFACES_NUMBER_OF_VIEWS
MyFaces specific context parameter name of maximum number of views in session.- See Also:
-
DEFAULT_MAX_ACTIVE_VIEW_SCOPES
public static final int DEFAULT_MAX_ACTIVE_VIEW_SCOPESDefault value of maximum active view scopes in session.- See Also:
-
-
Constructor Details
-
ViewScopeManager
public ViewScopeManager()
-
-
Method Details
-
getBean
Returns the CDI view scoped managed bean from the current Faces view scope, and auto-creates one if it doesn't exist.- Type Parameters:
T- The expected return type.- Parameters:
type- The contextual type of the CDI managed bean.context- The CDI context to create the CDI managed bean in.- Returns:
- The auto-created CDI view scoped managed bean from the current Faces view scope.
- Since:
- 4.5
-
getBean
Returns the CDI view scoped managed bean from the current Faces view scope, ornullif there is none.- Type Parameters:
T- The expected return type.- Parameters:
type- The contextual type of the CDI managed bean.- Returns:
- The CDI view scoped managed bean from the current Faces view scope, or
nullif there is none.
-
preDestroyView
public void preDestroyView()This method is invoked during view destroy byViewScopeEventListener, in that case destroy all beans in current active view scope. -
isUnloadRequest
Returnstrueif the current request is triggered by an unload request.- Parameters:
context- The involved faces context.- Returns:
trueif the current request is triggered by an unload request.- Since:
- 2.2
-
isUnloadRequest
Returnstrueif the given request is triggered by an unload request.- Parameters:
request- The involved request.- Returns:
trueif the given request is triggered by an unload request.- Since:
- 3.1
-