当前位置: 首页>>代码示例>>Java>>正文


Java Lifecycle类代码示例

本文整理汇总了Java中javax.faces.lifecycle.Lifecycle的典型用法代码示例。如果您正苦于以下问题:Java Lifecycle类的具体用法?Java Lifecycle怎么用?Java Lifecycle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Lifecycle类属于javax.faces.lifecycle包,在下文中一共展示了Lifecycle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFacesContext

import javax.faces.lifecycle.Lifecycle; //导入依赖的package包/类
/**
 * @param request
 * @param response
 * @return
 */
private FacesContext getFacesContext(final ServletRequest request, final ServletResponse response) {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    if (facesContext != null) {
        return facesContext;
    }

    FacesContextFactory contextFactory = (FacesContextFactory) FactoryFinder
            .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
    LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder
            .getFactory(FactoryFinder.LIFECYCLE_FACTORY);
    Lifecycle lifecycle = lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);

    ServletContext servletContext = ((HttpServletRequest) request).getSession().getServletContext();
    facesContext = contextFactory.getFacesContext(servletContext, request, response, lifecycle);

    return facesContext;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:23,代码来源:PrettyUrlFilter.java

示例2: getFacesContextImpl

import javax.faces.lifecycle.Lifecycle; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:34,代码来源:FacesHelper.java

示例3: jsfDispatchPage

import javax.faces.lifecycle.Lifecycle; //导入依赖的package包/类
/**
 * Jsf dispatch page.
 * 
 * @param fctx the faces context
 * @param page the pge
 */
private void jsfDispatchPage(FacesContext fctx, String page) {
  LifecycleFactory lf = (LifecycleFactory) FactoryFinder
      .getFactory(FactoryFinder.LIFECYCLE_FACTORY);
  Lifecycle lifecycle = lf.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
  ViewHandler vh = fctx.getApplication().getViewHandler();
  fctx.getViewRoot().setRenderKitId(vh.calculateRenderKitId(fctx));
  fctx.setViewRoot(vh.createView(fctx, page));
  
  // view rendering
  try {
    lifecycle.render(fctx);
  } catch (Exception e) {
    LOG.log(Level.INFO, "Error while rendering page. Attempting again" + page,
        e);
    lifecycle.render(fctx);
  } finally {
    fctx.release();
  }
}
 
开发者ID:GeoinformationSystems,项目名称:GeoprocessingAppstore,代码行数:26,代码来源:HtmlAdvancedWriter.java

示例4: getFacesContext

import javax.faces.lifecycle.Lifecycle; //导入依赖的package包/类
/**
 * Gets the faces context.
 *
 * @param request the request
 * @param response the response
 * @return the faces context
 */
protected FacesContext getFacesContext(HttpServletRequest request,
		HttpServletResponse response) {
	FacesContext facesContext = FacesContext.getCurrentInstance();
	if (facesContext == null) {

		FacesContextFactory contextFactory = (FacesContextFactory) FactoryFinder
				.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
		LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder
				.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
		Lifecycle lifecycle = lifecycleFactory
				.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);

		facesContext = contextFactory.getFacesContext(request.getSession()
				.getServletContext(), request, response, lifecycle);

		// set a new viewRoot, otherwise context.getViewRoot returns null
		UIViewRoot view = facesContext.getApplication().getViewHandler()
				.createView(facesContext, "");
		facesContext.setViewRoot(view);
	}
	return facesContext;
}
 
开发者ID:mattiamascia,项目名称:atask,代码行数:30,代码来源:DownloadCtr.java

示例5: getFacesContext

import javax.faces.lifecycle.Lifecycle; //导入依赖的package包/类
public FacesContext getFacesContext(ServletRequest request, ServletResponse response) {
	FacesContext facesContext = FacesContext.getCurrentInstance();
	if (facesContext != null) {
		return facesContext;
	}
	FacesContextFactory contextFactory = (FacesContextFactory) FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
	LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
	Lifecycle lifecycle = lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
	ServletContext servletContext = ((HttpServletRequest) request).getSession().getServletContext();
	facesContext = contextFactory.getFacesContext(servletContext, request, response, lifecycle);
	InnerFacesContext.setFacesContextAsCurrentInstance(facesContext);
	if (null == facesContext.getViewRoot()) {
		facesContext.setViewRoot(new UIViewRoot());
	}
	return facesContext;
}
 
开发者ID:wangyeee,项目名称:IBE-Secure-Message,代码行数:17,代码来源:SessionFilter.java

示例6: getFacesContext

import javax.faces.lifecycle.Lifecycle; //导入依赖的package包/类
@Override
public FacesContext getFacesContext(final Object context, final Object request, final Object response, final Lifecycle lifecycle)
		throws FacesException {
	FacesContext ctx = _delegate.getFacesContext(context, request, response, lifecycle);
	try {
		Class<?> vnClass = Class.forName("org.openntf.domino.xsp.helpers.OpenntfViewNavigatorEx");
	} catch (ClassNotFoundException e) {
		System.out.println("OpenntfFacesContextFactory unable to resolve ViewNavigatorEx either!");
	}
	try {
		Factory.setClassLoader(Thread.currentThread().getContextClassLoader());
		if (ctx instanceof com.ibm.xsp.context.FacesContextEx) {
			((com.ibm.xsp.context.FacesContextEx) ctx).addRequestListener(this);
		}
		// System.out.println("Created OpenntfFacesContext and setup factory");
	} catch (Throwable t) {
		t.printStackTrace();
	}
	return ctx;
}
 
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:21,代码来源:OpenntfFacesContextFactory.java

示例7: getFacesContext

import javax.faces.lifecycle.Lifecycle; //导入依赖的package包/类
@Override
public FacesContext getFacesContext(final Object context, final Object request, final Object response, final Lifecycle lifecycle)
		throws FacesException {
	FacesContext ctx = _delegate.getFacesContext(context, request, response, lifecycle);

	Factory.initThread(ODAPlatform.getAppThreadConfig(null));
	Factory.setSessionFactory(new XPageCurrentSessionFactory(), SessionType.CURRENT);
	Factory.setSessionFactory(new XPageSignerSessionFactory(false), SessionType.SIGNER);
	Factory.setSessionFactory(new XPageSignerSessionFactory(true), SessionType.SIGNER_FULL_ACCESS);

	// TODO RPr: This is probably the wrong locale. See ViewHandler.calculateLocale
	Factory.setUserLocale(ctx.getExternalContext().getRequestLocale());
	Factory.setClassLoader(ctx.getContextClassLoader());
	//		NotesContext ntx = NotesContext.getCurrent();

	if (ODAPlatform.isAppGodMode(null)) {
		ODAFacesContext localContext = new ODAFacesContext(ctx);
		attachListener(localContext);
		return localContext;
	} else {
		attachListener((FacesContextEx) ctx);
		return ctx;
	}
}
 
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:25,代码来源:ODAFacesContextFactory.java

示例8: getFacesContext

import javax.faces.lifecycle.Lifecycle; //导入依赖的package包/类
public FacesContext getFacesContext(final ServletRequest request,
		final ServletResponse response, HttpSession ses) {
	FacesContext facesContext = FacesContext.getCurrentInstance();
	if (facesContext != null) {
		return facesContext;
	}

	FacesContextFactory contextFactory = (FacesContextFactory) FactoryFinder
			.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
	LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder
			.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
	Lifecycle lifecycle = lifecycleFactory
			.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);

	ServletContext servletContext = ses.getServletContext();
	facesContext = contextFactory.getFacesContext(servletContext, request,
			response, lifecycle);
	InnerFacesContext.setFacesContextAsCurrentInstance(facesContext);
	if (null == facesContext.getViewRoot()) {
		UIViewRoot u = new UIViewRoot();
		u.setViewId("irgendwas");
		facesContext.setViewRoot(u);
	}

	return facesContext;
}
 
开发者ID:play4science,项目名称:gwap,代码行数:27,代码来源:FacesContextBuilder.java

示例9: getLifecycle

import javax.faces.lifecycle.Lifecycle; //导入依赖的package包/类
@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);
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:27,代码来源:DeltaSpikeLifecycleFactoryWrapper.java

示例10: getFacesContext

import javax.faces.lifecycle.Lifecycle; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:24,代码来源:DeltaSpikeFacesContextFactory.java

示例11: getFacesContext

import javax.faces.lifecycle.Lifecycle; //导入依赖的package包/类
@Override
@SuppressWarnings ("unchecked")
public FacesContext getFacesContext(
    Object context,
    Object request,
    Object response, 
    Lifecycle lifecycle)
{
  return new CacheRenderKit(_factory.getFacesContext(context, request, response, lifecycle));
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:11,代码来源:FacesContextFactoryImpl.java

示例12: MockFacesContext12

import javax.faces.lifecycle.Lifecycle; //导入依赖的package包/类
public MockFacesContext12(ExternalContext ec,
                          Lifecycle   lifecycle,
                          Application application)
{
  super(ec, lifecycle);
  elContext = createELContext(application);
  elContext.putContext(FacesContext.class, this);
  _app = application;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:10,代码来源:MockFacesContext12.java

示例13: doFilter

import javax.faces.lifecycle.Lifecycle; //导入依赖的package包/类
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);
        }
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:41,代码来源:FacesExtensionFilter.java

示例14: lookupBeanFromExternalServlet

import javax.faces.lifecycle.Lifecycle; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:44,代码来源:ContextUtil.java

示例15: lookupBeanFromExternalServlet

import javax.faces.lifecycle.Lifecycle; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:40,代码来源:SignupServlet.java


注:本文中的javax.faces.lifecycle.Lifecycle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。