javax.faces.lifecycle.Lifecycle Java Examples
The following examples show how to use
javax.faces.lifecycle.Lifecycle.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DeltaSpikeFacesContextFactory.java From deltaspike with Apache License 2.0 | 6 votes |
/** * Wrapps the created {@link javax.faces.context.FacesContext} with {@link DeltaSpikeFacesContextWrapper} * <p/> * {@inheritDoc} */ @Override public FacesContext getFacesContext(Object context, Object request, Object response, Lifecycle lifecycle) { FacesContext facesContext = this.wrappedFacesContextFactory.getFacesContext(context, request, response, lifecycle); if (facesContext == null || this.deactivated || facesContext instanceof DeltaSpikeFacesContextWrapper) { return facesContext; } lazyInit(); return new DeltaSpikeFacesContextWrapper(facesContext, clientWindow); }
Example #2
Source File: DeltaSpikeLifecycleFactoryWrapper.java From deltaspike with Apache License 2.0 | 6 votes |
@Override public Lifecycle getLifecycle(String s) { Lifecycle result = this.wrapped.getLifecycle(s); if (this.deactivated) { return result; } if (this.jsfVersionWithClientWindowDetected) { Class<? extends Lifecycle> lifecycleWrapperClass = ClassUtils.tryToLoadClassForName( "org.apache.deltaspike.jsf.impl.listener.request.JsfClientWindowAwareLifecycleWrapper"); try { return (Lifecycle) lifecycleWrapperClass.getConstructor(new Class[] { Lifecycle.class }) .newInstance(new DeltaSpikeLifecycleWrapper(result)); } catch (Exception e) { throw ExceptionUtils.throwAsRuntimeException(e); } } return new DeltaSpikeLifecycleWrapper(result); }
Example #3
Source File: ContextUtil.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Helper method to look up backing bean, when OUTSIDE faces in a servlet. * Don't forget to cast! * e.g. (TemplateBean) ContextUtil.lookupBean("template") * * @param beanName * @param request servlet request * @param response servlet response * @return the backing bean */ public static Serializable lookupBeanFromExternalServlet(String beanName, HttpServletRequest request, HttpServletResponse response) { // prepare lifecycle LifecycleFactory lFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY); Lifecycle lifecycle = lFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE); FacesContextFactory fcFactory = (FacesContextFactory) FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY); // in the integrated environment, we can't get the ServletContext from the // HttpSession of the request - because the HttpSession is webcontainer-wide, // its not tied to a particular servlet. ServletContext servletContext = M_servletContext; if (servletContext == null) { servletContext = request.getSession().getServletContext(); } FacesContext facesContext = fcFactory.getFacesContext(servletContext, request, response, lifecycle); ApplicationFactory factory = (ApplicationFactory) FactoryFinder. getFactory( FactoryFinder.APPLICATION_FACTORY); Application application = factory.getApplication(); Serializable bean = (Serializable) application.getVariableResolver().resolveVariable( facesContext, beanName); return bean; }
Example #4
Source File: JsfClientWindowAwareLifecycleWrapper.java From deltaspike with Apache License 2.0 | 5 votes |
private static void delegateAttachWindow(FacesContext facesContext, Lifecycle lifecycle) throws Exception { //if there is an external wrapper (e.g. in case of other libs), we have to check //the version of javax.faces.lifecycle.Lifecycle (>= or < v2.2) //without the check and an old lib (in the classpath) #attachWindow would get ignored without exception if (lifecycle instanceof LifecycleWrapper /*autom. provides #attachWindow*/ || lifecycle.getClass().getDeclaredMethod("attachWindow", FacesContext.class) != null) { lifecycle.attachWindow(facesContext); } }
Example #5
Source File: JsfClientWindowAwareLifecycleWrapper.java From deltaspike with Apache License 2.0 | 5 votes |
@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)); } } }
Example #6
Source File: SignupServlet.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Helper method to look up backing bean, when OUTSIDE faces in a servlet. * Don't forget to cast! e.g. (TemplateBean) * ContextUtil.lookupBean("template") * * @param beanName * @param request * servlet request * @param response * servlet response * @return the backing bean */ public Serializable lookupBeanFromExternalServlet(String beanName, HttpServletRequest request, HttpServletResponse response) { // prepare lifecycle LifecycleFactory lFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY); Lifecycle lifecycle = lFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE); FacesContextFactory fcFactory = (FacesContextFactory) FactoryFinder .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY); // in the integrated environment, we can't get the ServletContext from // the // HttpSession of the request - because the HttpSession is // webcontainer-wide, // its not tied to a particular servlet. if (this.servletContext == null) { servletContext = request.getSession().getServletContext(); } FacesContext facesContext = fcFactory.getFacesContext(servletContext, request, response, lifecycle); ApplicationFactory factory = (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY); Application application = factory.getApplication(); Serializable bean = (Serializable) application.getVariableResolver().resolveVariable(facesContext, beanName); return bean; }
Example #7
Source File: ContextUtil.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Helper method to look up backing bean, when OUTSIDE faces in a servlet. * Don't forget to cast! * e.g. (TemplateBean) ContextUtil.lookupBean("template") * * @param beanName * @param request servlet request * @param response servlet response * @return the backing bean */ public static Serializable lookupBeanFromExternalServlet(String beanName, HttpServletRequest request, HttpServletResponse response) { // prepare lifecycle LifecycleFactory lFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY); Lifecycle lifecycle = lFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE); FacesContextFactory fcFactory = (FacesContextFactory) FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY); // in the integrated environment, we can't get the ServletContext from the // HttpSession of the request - because the HttpSession is webcontainer-wide, // its not tied to a particular servlet. ServletContext servletContext = M_servletContext; if (servletContext == null) { servletContext = request.getSession().getServletContext(); } FacesContext facesContext = fcFactory.getFacesContext(servletContext, request, response, lifecycle); ApplicationFactory factory = (ApplicationFactory) FactoryFinder. getFactory( FactoryFinder.APPLICATION_FACTORY); Application application = factory.getApplication(); Serializable bean = (Serializable) application.getVariableResolver().resolveVariable( facesContext, beanName); return bean; }
Example #8
Source File: SignupServlet.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Helper method to look up backing bean, when OUTSIDE faces in a servlet. * Don't forget to cast! e.g. (TemplateBean) * ContextUtil.lookupBean("template") * * @param beanName * @param request * servlet request * @param response * servlet response * @return the backing bean */ public Serializable lookupBeanFromExternalServlet(String beanName, HttpServletRequest request, HttpServletResponse response) { // prepare lifecycle LifecycleFactory lFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY); Lifecycle lifecycle = lFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE); FacesContextFactory fcFactory = (FacesContextFactory) FactoryFinder .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY); // in the integrated environment, we can't get the ServletContext from // the // HttpSession of the request - because the HttpSession is // webcontainer-wide, // its not tied to a particular servlet. if (this.servletContext == null) { servletContext = request.getSession().getServletContext(); } FacesContext facesContext = fcFactory.getFacesContext(servletContext, request, response, lifecycle); ApplicationFactory factory = (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY); Application application = factory.getApplication(); Serializable bean = (Serializable) application.getVariableResolver().resolveVariable(facesContext, beanName); return bean; }
Example #9
Source File: MobileActionListener.java From journaldev with MIT License | 5 votes |
public void listAllPhaseListeners() { LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder .getFactory(FactoryFinder.LIFECYCLE_FACTORY); Lifecycle applicationLifecycle = lifecycleFactory .getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE); PhaseListener phaseListeners[] = applicationLifecycle .getPhaseListeners(); for (PhaseListener phaseListener : phaseListeners) { System.out.println(phaseListener.getPhaseId()); } }
Example #10
Source File: ExtValLifecycleFactory.java From tomee with Apache License 2.0 | 4 votes |
@Override public void addLifecycle(String lifecycleId, Lifecycle lifecycle) { wrapped.addLifecycle(lifecycleId, lifecycle); }
Example #11
Source File: ExtValLifecycleFactory.java From tomee with Apache License 2.0 | 4 votes |
@Override public Lifecycle getLifecycle(String lifecycleId) { return new LifecycleWrapper(wrapped.getLifecycle(lifecycleId)); }
Example #12
Source File: ExtValLifecycleFactory.java From tomee with Apache License 2.0 | 4 votes |
private LifecycleWrapper(Lifecycle wrapped) { this.wrapped = wrapped; }
Example #13
Source File: DeltaSpikeLifecycleFactoryWrapper.java From deltaspike with Apache License 2.0 | 4 votes |
@Override public void addLifecycle(String s, Lifecycle lifecycle) { wrapped.addLifecycle(s, lifecycle); }
Example #14
Source File: DeltaSpikeLifecycleWrapper.java From deltaspike with Apache License 2.0 | 4 votes |
DeltaSpikeLifecycleWrapper(Lifecycle wrapped) { this.wrapped = wrapped; }
Example #15
Source File: DeltaSpikeLifecycleWrapper.java From deltaspike with Apache License 2.0 | 4 votes |
Lifecycle getWrapped() { return wrapped; }
Example #16
Source File: JsfClientWindowAwareLifecycleWrapper.java From deltaspike with Apache License 2.0 | 4 votes |
public JsfClientWindowAwareLifecycleWrapper(Lifecycle wrapped) { this.wrapped = wrapped; }
Example #17
Source File: JsfClientWindowAwareLifecycleWrapper.java From deltaspike with Apache License 2.0 | 4 votes |
@Override public Lifecycle getWrapped() { return wrapped; }