javax.faces.lifecycle.LifecycleFactory Java Examples

The following examples show how to use javax.faces.lifecycle.LifecycleFactory. 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: DeltaSpikeLifecycleFactoryWrapper.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
/**
 * Constructor for wrapping the given {@link LifecycleFactory}
 *
 * @param wrapped lifecycle-factory which should be wrapped
 */
public DeltaSpikeLifecycleFactoryWrapper(LifecycleFactory wrapped)
{
    this.wrapped = wrapped;
    this.deactivated = !ClassDeactivationUtils.isActivated(getClass());
    boolean jsfVersionWithClientWindowDetected =
        ClassUtils.tryToLoadClassForName(JsfModuleConfig.CLIENT_WINDOW_CLASS_NAME) != null;

    if (jsfVersionWithClientWindowDetected && ClassUtils.tryToLoadClassForName(
        "org.apache.deltaspike.jsf.impl.listener.request.JsfClientWindowAwareLifecycleWrapper") == null)
    {
        jsfVersionWithClientWindowDetected = false;
        JsfUtils.logWrongModuleUsage(getClass().getName());
    }
    this.jsfVersionWithClientWindowDetected = jsfVersionWithClientWindowDetected;
}
 
Example #2
Source File: MobileActionListener.java    From journaldev with MIT License 5 votes vote down vote up
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 #3
Source File: ContextUtil.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * 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: SignupServlet.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * 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 #5
Source File: ContextUtil.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * 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 #6
Source File: SignupServlet.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * 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: ExtValLifecycleFactory.java    From tomee with Apache License 2.0 4 votes vote down vote up
public ExtValLifecycleFactory(LifecycleFactory wrapped) {
    this.wrapped = wrapped;
}
 
Example #8
Source File: ExtValLifecycleFactory.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Override
public LifecycleFactory getWrapped() {
    return wrapped;
}
 
Example #9
Source File: MockedJsf2TestContainer.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
protected void initLifecycle()
{
    LifecycleFactory lifecycleFactory =
            (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
    this.lifecycle = lifecycleFactory.getLifecycle(getLifecycleId());
}
 
Example #10
Source File: MockedJsf2TestContainer.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
protected String getLifecycleId()
{
    return LifecycleFactory.DEFAULT_LIFECYCLE;
}
 
Example #11
Source File: DeltaSpikeLifecycleFactoryWrapper.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
@Override
public LifecycleFactory getWrapped()
{
    return wrapped;
}