Exemple #1
0
  private void restoreView(FacesContext context) throws FacesException {
    Application app = context.getApplication();

    if (app instanceof ApplicationImpl) ((ApplicationImpl) app).initRequest();

    ViewHandler view = app.getViewHandler();

    view.initView(context);

    UIViewRoot viewRoot = context.getViewRoot();

    if (viewRoot != null) {
      ExternalContext extContext = context.getExternalContext();

      viewRoot.setLocale(extContext.getRequestLocale());

      doSetBindings(context.getELContext(), viewRoot);

      return;
    }

    String viewId = calculateViewId(context);

    String renderKitId = view.calculateRenderKitId(context);

    RenderKitFactory renderKitFactory =
        (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);

    RenderKit renderKit = renderKitFactory.getRenderKit(context, renderKitId);

    ResponseStateManager stateManager = renderKit.getResponseStateManager();

    if (stateManager.isPostback(context)) {
      viewRoot = view.restoreView(context, viewId);

      if (viewRoot != null) {
        doSetBindings(context.getELContext(), viewRoot);
      } else {
        // XXX: backward compat issues with ViewHandler and StateManager

        // throw new ViewExpiredException(L.l("{0} is an expired view", viewId));

        context.renderResponse();

        viewRoot = view.createView(context, viewId);

        context.setViewRoot(viewRoot);
      }

      context.setViewRoot(viewRoot);
    } else {
      context.renderResponse();

      viewRoot = view.createView(context, viewId);

      context.setViewRoot(viewRoot);
    }
  }
  /**
   * 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();
    }
  }
  /** @see javax.faces.context.FacesContext#isPostback() */
  @Override
  public boolean isPostback() {

    assertNotReleased();
    Boolean postback = (Boolean) this.getAttributes().get(POST_BACK_MARKER);
    if (postback == null) {
      RenderKit rk = this.getRenderKit();
      if (rk != null) {
        postback = rk.getResponseStateManager().isPostback(this);
      } else {
        // ViewRoot hasn't been set yet, so calculate the RK
        ViewHandler vh = this.getApplication().getViewHandler();
        String rkId = vh.calculateRenderKitId(this);
        postback = RenderKitUtils.getResponseStateManager(this, rkId).isPostback(this);
      }
      this.getAttributes().put(POST_BACK_MARKER, postback);
    }

    return postback;
  }
 public String calculateRenderKitId(FacesContext context) {
   return viewHandler.calculateRenderKitId(context);
 }
 public String calculateRenderKitId(FacesContext arg0) {
   return m_wrapped.calculateRenderKitId(arg0);
 }