miercuri, 4 martie 2015

Detecting stateless views programmatically

Programmatically speaking, you can detect if a view is stateless by using the following options:

• In view or page, enter the following code:
<f:view transient="true">
 Is Stateless (using transient) ? #{facesContext.viewRoot.transient}
 ...
</f:view>

• In view or page, enter the following code. This works only for the postback requests:
Is Stateless (using stateless) ?
#{facesContext.postback ? facesContext.renderKit.responseStateManager.isStateless(facesContext, null) : 'Not postback yet!'}

• In backing bean, enter the following code:
  ...
 FacesContext facesContext = FacesContext.getCurrentInstance();
 UIViewRoot uiViewRoot = facesContext.getViewRoot();
 logger.log(Level.INFO, "Is stateless (using isTransient) ? {0}",
 uiViewRoot.isTransient());
 logger.log(Level.INFO, "Is stateless (using isStateless) ? {0}", facesContext.getRenderKit().getResponseStateManager().isStateless(facesContext, null));
 ...

Niciun comentariu:

Trimiteți un comentariu