javax.faces.lifecycle.Lifecycle类的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(129)

本文整理了Java中javax.faces.lifecycle.Lifecycle类的一些代码示例,展示了Lifecycle类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Lifecycle类的具体详情如下:
包路径:javax.faces.lifecycle.Lifecycle
类名称:Lifecycle

Lifecycle介绍

[英]Lifecycle manages the processing of the entire lifecycle of a particular JavaServer Faces request. It is responsible for executing all of the phases that have been defined by the JavaServer Faces Specification, in the specified order, unless otherwise directed by activities that occurred during the execution of each phase.

An instance of Lifecycle is created by calling the getLifecycle() method of LifecycleFactory, for a specified lifecycle identifier. Because this instance is shared across multiple simultaneous requests, it must be implemented in a thread-safe manner.
[中]Lifecycle管理特定JavaServer请求的整个生命周期的处理。它负责按照指定的顺序执行JavaServerFaces规范定义的所有阶段,除非每个阶段执行期间发生的活动另有指示。
Lifecycle的实例是通过为指定的生命周期标识符调用LifecycleFactory的getLifecycle()方法创建的。由于此实例在多个同时请求之间共享,因此必须以线程安全的方式实现。

代码示例

代码示例来源:origin: org.apache.myfaces.extensions.cdi.modules/myfaces-extcdi-jsf12-module-impl

CodiLifecycleWrapper(Lifecycle wrapped, List<PhaseListener> phaseListeners)
{
  this.wrapped = wrapped;
  for (PhaseListener phaseListener : phaseListeners)
  {
    this.wrapped.addPhaseListener(phaseListener);
  }
}

代码示例来源:origin: org.springframework.webflow/org.springframework.faces

/**
 * Delegates to the wrapped {@link Lifecycle}.
 * @throws FacesException
 */
public void render(FacesContext context) throws FacesException {
  delegate.render(context);
}

代码示例来源:origin: org.seasar.teeda/teeda-core

private void restoreView(FacesContext facesContext) {
  facesContext.renderResponse();
  // call restore phase only
  lifecycle.execute(facesContext);
}

代码示例来源:origin: org.glassfish/javax.faces

private void executeLifecyle(FacesContext context) throws IOException, ServletException {
  try {
    ResourceHandler handler = context.getApplication().getResourceHandler();
    if (handler.isResourceRequest(context)) {
      handler.handleResourceRequest(context);
    } else {
      lifecycle.attachWindow(context);
      lifecycle.execute(context);
      lifecycle.render(context);
    }
  } catch (FacesException e) {
    Throwable t = e.getCause();
    
    if (t == null) {
      throw new ServletException(e.getMessage(), e);
    } 
    
    if (t instanceof ServletException) {
      throw (ServletException) t;
    } 
    
    if (t instanceof IOException) {
      throw (IOException) t;
    } 
      
    throw new ServletException(t.getMessage(), t);
  }
}

代码示例来源:origin: spring-projects/spring-webflow

/**
 * Performs the standard duties of the JSF RENDER_RESPONSE phase.
 */
public void render() throws IOException {
  FacesContext facesContext = FlowFacesContext.getCurrentInstance();
  if (facesContext.getResponseComplete()) {
    return;
  }
  facesContext.setViewRoot(this.viewRoot);
  try {
    logger.debug("Asking faces lifecycle to render");
    this.facesLifecycle.render(facesContext);
  } finally {
    logger.debug("View rendering complete");
    facesContext.responseComplete();
  }
}

代码示例来源:origin: org.apache.myfaces.core/myfaces-impl

public void beforePhase(final PhaseEvent event)
{
  if (!initialized)
  {
    synchronized(this)
    {
      if (!initialized)
      {
        FacesContext facesContext = event.getFacesContext();
        facesContext = (facesContext == null) ? FacesContext.getCurrentInstance() : facesContext;
        _resolverBuilder.build(facesContext, _resolverForJSP);
        LifecycleFactory factory = (LifecycleFactory) 
            FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
        for (Iterator<String> iter = factory.getLifecycleIds(); iter.hasNext();)
        {
          factory.getLifecycle(iter.next()).removePhaseListener(this);
        }
        
        initialized = true;
      }
    }
  }
}

代码示例来源:origin: org.apache.struts/struts2-jsf-plugin

/**
 * Informs phase listeners after a phase is executed
 *
 * @param facesContext
 *            The current faces context
 * @param phaseId
 *            The phase id that was executed
 */
protected void informPhaseListenersAfter(FacesContext facesContext,
    PhaseId phaseId) {
  Lifecycle lifecycle = getLifecycle();
  PhaseListener[] phaseListeners = lifecycle.getPhaseListeners();
  for (int i = 0; i < phaseListeners.length; i++) {
    PhaseListener phaseListener = phaseListeners[i];
    int listenerPhaseId = phaseListener.getPhaseId().getOrdinal();
    if (listenerPhaseId == PhaseId.ANY_PHASE.getOrdinal()
        || listenerPhaseId == phaseId.getOrdinal()) {
      phaseListener.afterPhase(new PhaseEvent(FacesContext
          .getCurrentInstance(), phaseId, lifecycle));
    }
  }
}

代码示例来源:origin: org.apache.deltaspike.modules/deltaspike-jsf-module-impl-ee6

/**
 * Performs cleanup tasks after the rendering process
 */
@Override
public void render(FacesContext facesContext)
{
  this.wrapped.render(facesContext);
  
  if (facesContext.getViewRoot() != null && facesContext.getViewRoot().getViewId() != null)
  {
    ViewAccessContext viewAccessContext = contextExtension.getViewAccessScopedContext();
    if (viewAccessContext != null)
    {
      viewAccessContext.onProcessingViewFinished(facesContext.getViewRoot().getViewId());
    }
  }
}

代码示例来源:origin: org.springframework.webflow/org.springframework.faces

public void processUserEvent() {
  FacesContext facesContext = FlowFacesContext.newInstance(requestContext, facesLifecycle);
  facesContext.setViewRoot(viewRoot);
  try {
    if (restored && !facesContext.getRenderResponse() && !facesContext.getResponseComplete()) {
      facesLifecycle.execute(facesContext);
    }
    if (JsfUtils.isPortlet(facesContext)) {
      requestContext.getFlashScope().put(ViewRootHolder.VIEW_ROOT_HOLDER_KEY,
          new ViewRootHolder(getViewRoot()));
    }
  } finally {
    facesContext.release();
  }
}

代码示例来源:origin: spring-projects/spring-webflow

/**
 * Executes postback-processing portions of the standard JSF lifecycle including APPLY_REQUEST_VALUES through
 * INVOKE_APPLICATION.
 */
public void processUserEvent() {
  FacesContext facesContext = FlowFacesContext.getCurrentInstance();
  // Must respect these flags in case user set them during RESTORE_VIEW phase
  if (!facesContext.getRenderResponse() && !facesContext.getResponseComplete()) {
    this.facesLifecycle.execute(facesContext);
  }
}

代码示例来源:origin: org.apache.myfaces.extensions.cdi.bundles/myfaces-extcdi-bundle-jsf20

/**
 * Broadcasts {@link org.apache.myfaces.extensions.cdi.core.api.startup.event.StartupEvent} and
 * {@link org.apache.myfaces.extensions.cdi.jsf.api.listener.request.BeforeFacesRequest} btw.
 * {@link org.apache.myfaces.extensions.cdi.jsf.api.listener.request.AfterFacesRequest}
 * <p/>
 * {@inheritDoc}
 */
public void execute(FacesContext facesContext)
{
  broadcastApplicationStartupBroadcaster();
  broadcastBeforeFacesRequestEvent(facesContext);
  WindowHandler windowHandler = CodiUtils.getContextualReferenceByClass(WindowHandler.class);
  if (windowHandler instanceof LifecycleAwareWindowHandler)
  {
    ((LifecycleAwareWindowHandler) windowHandler).beforeLifecycleExecute(facesContext);
    if (facesContext.getResponseComplete())
    {
      // no further processing
      return;
    }
  }
  wrapped.execute(facesContext);
}

代码示例来源:origin: frenchc/jetm

@Override
public void render(FacesContext context) throws FacesException {
 try {
  delegate.render(context);
 } finally {
  EtmPoint requestPoint = (EtmPoint) context.getAttributes().get(EtmJsfPlugin.ROOT_ETM_POINT);
  if (requestPoint != null) {
   requestPoint.collect();
   context.getAttributes().remove(EtmJsfPlugin.ROOT_ETM_POINT);
  }
 }
}

代码示例来源:origin: frenchc/jetm

@Override
public void execute(FacesContext context) throws FacesException {
 EtmPoint requestPoint = EtmManager.getEtmMonitor().createPoint(getDefaultRequestName(context));
 context.getAttributes().put(EtmJsfPlugin.ROOT_ETM_POINT, requestPoint);
 delegate.execute(context);
}

代码示例来源:origin: org.springframework.webflow/org.springframework.faces

/**
 * Delegates to the wrapped {@link Lifecycle}.
 */
public void removePhaseListener(PhaseListener listener) {
  delegate.removePhaseListener(listener);
}

代码示例来源:origin: org.apache.myfaces.extensions.cdi.bundles/myfaces-extcdi-bundle-jsf20

/**
 * {@inheritDoc}
 */
public PhaseListener[] getPhaseListeners()
{
  return this.wrapped.getPhaseListeners();
}

代码示例来源:origin: javax/javaee-web-api

@Override
public void execute(FacesContext context) throws FacesException {
  getWrapped().execute(context);
}

代码示例来源:origin: com.sun.faces/jsf-impl

public static void removeELResolverInitPhaseListener() {
  LifecycleFactory factory = (LifecycleFactory)
      FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
  // remove ourselves from the list of listeners maintained by
  // the lifecycle instances
  for (Iterator<String> i = factory.getLifecycleIds(); i.hasNext();) {
    Lifecycle lifecycle = factory.getLifecycle(i.next());
    for (PhaseListener cur : lifecycle.getPhaseListeners()) {
      if (cur instanceof ELResolverInitPhaseListener) {
        lifecycle.removePhaseListener(cur);
      }
    }
  }
}

代码示例来源:origin: com.liferay.faces/liferay-faces-bridge-impl

protected void attachClientWindowToLifecycle(FacesContext facesContext, Lifecycle lifecycle) {
    lifecycle.attachWindow(facesContext);
  }
}

代码示例来源:origin: org.glassfish/jakarta.faces

private void executeLifecyle(FacesContext context) throws IOException, ServletException {
  try {
    ResourceHandler handler = context.getApplication().getResourceHandler();
    if (handler.isResourceRequest(context)) {
      handler.handleResourceRequest(context);
    } else {
      lifecycle.attachWindow(context);
      lifecycle.execute(context);
      lifecycle.render(context);
    }
  } catch (FacesException e) {
    Throwable t = e.getCause();
    
    if (t == null) {
      throw new ServletException(e.getMessage(), e);
    } 
    
    if (t instanceof ServletException) {
      throw (ServletException) t;
    } 
    
    if (t instanceof IOException) {
      throw (IOException) t;
    } 
      
    throw new ServletException(t.getMessage(), t);
  }
}

代码示例来源:origin: org.springframework.webflow/spring-faces

/**
 * Performs the standard duties of the JSF RENDER_RESPONSE phase.
 */
public void render() throws IOException {
  FacesContext facesContext = FlowFacesContext.getCurrentInstance();
  if (facesContext.getResponseComplete()) {
    return;
  }
  facesContext.setViewRoot(this.viewRoot);
  try {
    logger.debug("Asking faces lifecycle to render");
    this.facesLifecycle.render(facesContext);
  } finally {
    logger.debug("View rendering complete");
    facesContext.responseComplete();
  }
}

相关文章