marți, 26 ianuarie 2016

[OmniFaces utilities (2.3)] - Check if the given CDI managed bean scope is active


[OmniFaces utilities] The isActive() returns true when the given CDI managed bean scope is active. I.e., all beans therein can be accessed without facing ContextNotActiveException.

Method:
Usage:

For example, you can test if the request scope is active like this:

import org.omnifaces.util.Beans;
...
boolean isrequestscopeactive = Beans.isActive(RequestScoped.class);
if (isrequestscopeactive){
    // do something
} else {
    // do something else

}

Niciun comentariu:

Trimiteți un comentariu