use of javax.faces.lifecycle.Lifecycle in project deltaspike by apache.
the class JsfClientWindowAwareLifecycleWrapper method attachWindow.
@Override
public void attachWindow(FacesContext facesContext) {
lazyInit();
boolean delegateWindowHandling = ClientWindowConfig.ClientWindowRenderMode.DELEGATED.equals(clientWindowConfig.getClientWindowRenderMode(facesContext));
if (delegateWindowHandling) {
try {
//the first wrapper is always DeltaSpikeLifecycleWrapper which can't extend from LifecycleWrapper
Lifecycle externalWrapper = ((DeltaSpikeLifecycleWrapper) this.wrapped).getWrapped();
delegateAttachWindow(facesContext, externalWrapper);
} catch (Exception e) {
try {
attachWindowOnUnwrappedInstance(facesContext, this.wrapped);
} catch (Exception e1) {
throw ExceptionUtils.throwAsRuntimeException(e);
}
}
} else {
ClientWindow clientWindow = BeanProvider.getContextualReference(ClientWindow.class);
//trigger init - might lead to a redirect -> response-complete
String windowId = clientWindow.getWindowId(facesContext);
if (!facesContext.getResponseComplete() && !"default".equals(windowId)) {
facesContext.getExternalContext().setClientWindow(new ClientWindowAdapter(clientWindow));
}
}
}
use of javax.faces.lifecycle.Lifecycle in project acs-community-packaging by Alfresco.
the class FacesHelper method getFacesContextImpl.
/**
* Return a valid FacesContext for the specific context, request and response.
* The FacesContext can be constructor for Servlet and Portlet use.
*
* @param context ServletContext or PortletContext
* @param request ServletRequest or PortletRequest
* @param response ServletReponse or PortletResponse
*
* @return FacesContext
*/
private static FacesContext getFacesContextImpl(Object request, Object response, Object context, String viewRoot) {
FacesContextFactory contextFactory = (FacesContextFactory) FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
Lifecycle lifecycle = lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
// Doesn't set this instance as the current instance of FacesContext.getCurrentInstance
FacesContext facesContext = contextFactory.getFacesContext(context, request, response, lifecycle);
// Set using our inner class
InnerFacesContext.setFacesContextAsCurrent(facesContext);
// set a new viewRoot, otherwise context.getViewRoot returns null
if (viewRoot == null) {
viewRoot = FacesHelper.BROWSE_VIEW_ID;
}
UIViewRoot view = facesContext.getApplication().getViewHandler().createView(facesContext, viewRoot);
facesContext.setViewRoot(view);
return facesContext;
}
use of javax.faces.lifecycle.Lifecycle in project ma-core-public by infiniteautomation.
the class FacesExtensionFilter method doFilter.
/* (non-Javadoc)
* @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
*/
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
FacesContextFactory contextFactory = (FacesContextFactory) FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
Lifecycle lifecycle = lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
// Either set a private member
// servletContext = filterConfig.getServletContext();
// in your filter init() method or set it here like this:
// ServletContext servletContext =
// ((HttpServletRequest) request).getSession().getServletContext();
// Note that the above line would fail if you are using any other
// protocol than http
// Doesn't set this instance as the current instance of
// FacesContext.getCurrentInstance
FacesContext facesContext = contextFactory.getFacesContext(servletContext, request, response, lifecycle);
// Set using our inner class
InnerFacesContext.setFacesContextAsCurrentInstance(facesContext);
try {
// call the filter chain
chain.doFilter(request, response);
} finally {
// Clean up after ourselves as FacesContext is a ThreadLocal object
try {
facesContext.release();
} catch (IllegalStateException ex) {
// Perhaps the FacesContext has already been released?
log.warn("Double release of faces context?", ex);
}
}
}
Aggregations