/**
   * Returns <code>true</code> if optimized PPR is enabled for this request.
   *
   * @return <code>true</code> if optimized PPR is enabled for this request
   */
  public static boolean isOptimizedPPREnabled(FacesContext context, boolean checkIsPPR) {
    boolean optimizedPPREnabled = false;

    if (!checkIsPPR
        || (PartialPageUtils.isPartialRequest(context) && PartialPageUtils.isPPRActive(context))) {
      Map<Object, Object> contextAttributes = context.getAttributes();

      Object optimizedPPR = contextAttributes.get(_OPTIMIZED_PPR_ENABLED_PROP);

      if (optimizedPPR != null) {
        optimizedPPREnabled = ((Boolean) optimizedPPR).booleanValue();
      } else {
        // default optimized ppr to off
        optimizedPPREnabled = "on".equalsIgnoreCase(_getPprOptimization(context));

        // cache the result into the context attributes
        contextAttributes.put(_OPTIMIZED_PPR_ENABLED_PROP, optimizedPPREnabled);
      }
    }

    return optimizedPPREnabled;
  }
  @SuppressWarnings("unchecked")
  @Override
  protected void decode(
      FacesContext facesContext,
      UIComponent component,
      @SuppressWarnings("unused") FacesBean facesBean,
      String clientId) {
    super.decode(facesContext, component, facesBean, clientId);

    RequestContext afContext = RequestContext.getCurrentInstance();
    // See if a ReturnEvent is waiting for us.  We don't deliver
    // the ReturnEvent - we just use its value
    ReturnEvent returnEvent = afContext.getDialogService().getReturnEvent(component);
    if (returnEvent != null) {
      afContext.addPartialTarget(component);
      queueReturnEvent(facesContext, component, returnEvent);
    } else {
      Map<String, String> parameterMap = facesContext.getExternalContext().getRequestParameterMap();

      Object source = parameterMap.get("source");
      clientId = clientId == null ? component.getClientId(facesContext) : clientId;
      if ((source != null) && source.equals(clientId)) {
        Object part = parameterMap.get(_PART_PARAMETER);
        if (_BUTTON_PART.equals(part)) {
          // Force partial rendering (if we're launching a window)
          // =-=AEW I don't believe this is necessary;  I believe
          // we've already got "partial" turned on
          TrinidadAgent agent = AgentUtil.getAgent(facesContext);
          if (XhtmlUtils.supportsSeparateWindow(agent))
            PartialPageUtils.forcePartialRendering(facesContext);

          queueActionEvent(facesContext, component);
        }
        // else ???
      }
    }
  }
Пример #3
0
  @Override
  protected void encodeAll(
      FacesContext context, RenderingContext arc, UIComponent component, FacesBean bean)
      throws IOException {
    // Since Train is a naming container, we can be more
    // efficient about skipping its children
    if (!PartialPageUtils.containsPprTargets(arc, component, getClientId(context, component))) {
      return;
    }

    if (!(component instanceof UIXProcess)) {
      throw new ClassCastException(
          _LOG.getMessage(
              "TRAINRENDERER_ONLY_RENDERS_INSTANCE",
              new Object[] {UIXProcess.class.getName(), component.getClass().getName()}));
    }

    if (arc.getFormData() == null) {
      _LOG.warning("TRAIN_MUST_INSIDE_FORM");
      return;
    }

    UIXProcess process = (UIXProcess) component;
    UIComponent stamp = process.getNodeStamp();

    if (stamp != null) {
      Train train = new Train(context, arc, process, stamp);
      try {
        process.setRowKey(train.getFocusRowKey());

        // Renders some fields and scripts
        _renderHiddenFields(context, arc, train);

        ResponseWriter writer = context.getResponseWriter();

        // Need to render the frame even if there's no visible station
        // to support PPR.
        writer.startElement(XhtmlConstants.TABLE_ELEMENT, component);
        process.setRowKey(train.getInitialRowKey());
        renderId(context, component);
        renderAllAttributes(context, arc, bean);
        // Does not seem to be needed and this is not XHTML 1.0 Strict compliant
        // writer.writeAttribute("align", "center", null);

        if (!train.getStations().isEmpty()) {
          process.setRowKey(train.getFocusRowKey());

          // There're visible stations currently, let render them.
          writer.startElement(XhtmlConstants.TABLE_BODY_ELEMENT, null);
          _renderTrain(context, arc, process, bean, stamp, train);
          writer.endElement(XhtmlConstants.TABLE_BODY_ELEMENT);
        }

        writer.endElement(XhtmlConstants.TABLE_ELEMENT);
      } finally {
        // Always restore the model, whatever happened
        process.setRowKey(train.getInitialRowKey());
      }
    } else {
      _LOG.warning("NODESTAMP_FACET_NOT_FOUND_FOR_TRAIN", component);
    }
    /*
      _encodeChildren(context, arc, process, stamp, trainState, length);
    */
  }