示例#1
0
    public VisitResult visit(VisitContext context, UIComponent comp) {
      try {

        if (curPhase == PhaseId.APPLY_REQUEST_VALUES) {

          // RELEASE_PENDING handle immediate request(s)
          // If the user requested an immediate request
          // Make sure to set the immediate flag here.

          comp.processDecodes(ctx);
        } else if (curPhase == PhaseId.PROCESS_VALIDATIONS) {
          comp.processValidators(ctx);
        } else if (curPhase == PhaseId.UPDATE_MODEL_VALUES) {
          comp.processUpdates(ctx);
        } else if (curPhase == PhaseId.RENDER_RESPONSE) {

          PartialResponseWriter writer = ctx.getPartialViewContext().getPartialResponseWriter();

          writer.startUpdate(comp.getClientId(ctx));
          try {
            // do the default behavior...
            comp.encodeAll(ctx);
          } catch (Exception ce) {
            if (LOGGER.isLoggable(Level.SEVERE)) {
              LOGGER.severe(ce.toString());
            }
            if (LOGGER.isLoggable(Level.FINE)) {
              LOGGER.log(Level.FINE, ce.toString(), ce);
            }
          }
          writer.endUpdate();
        } else {
          throw new IllegalStateException(
              "I18N: Unexpected "
                  + "PhaseId passed to "
                  + " PhaseAwareContextCallback: "
                  + curPhase.toString());
        }
      } catch (IOException ex) {
        ex.printStackTrace();
      }

      // Once we visit a component, there is no need to visit
      // its children, since processDecodes/Validators/Updates and
      // encodeAll() already traverse the subtree.  We return
      // VisitResult.REJECT to supress the subtree visit.
      return VisitResult.REJECT;
    }
  public VisitResult visit(VisitContext context, UIComponent target) {
    String metaComponentId =
        (String) facesContext.getAttributes().get(ExtendedVisitContext.META_COMPONENT_ID);
    if (metaComponentId != null) {
      MetaComponentProcessor executor = (MetaComponentProcessor) target;
      executor.processMetaComponent(facesContext, metaComponentId);
    } else if (phaseId == PhaseId.APPLY_REQUEST_VALUES) {
      target.processDecodes(facesContext);
    } else if (phaseId == PhaseId.PROCESS_VALIDATIONS) {
      target.processValidators(facesContext);
    } else if (phaseId == PhaseId.UPDATE_MODEL_VALUES) {
      target.processUpdates(facesContext);
    } else {
      throw new IllegalArgumentException(phaseId.toString());
    }

    return VisitResult.REJECT;
  }
示例#3
0
 protected final void processComponent(
     FacesContext context, UIComponent component, PhaseId phaseId) {
   if (component != null) {
     if (phaseId == PhaseId.APPLY_REQUEST_VALUES) {
       component.processDecodes(context);
     } else if (phaseId == PhaseId.PROCESS_VALIDATIONS) {
       component.processValidators(context);
     } else if (phaseId == PhaseId.UPDATE_MODEL_VALUES) {
       component.processUpdates(context);
     } else if (phaseId == PhaseId.RENDER_RESPONSE) {
       try {
         ComponentSupport.encodeRecursive(context, component);
       } catch (IOException err) {
         log.error("Error while rendering component " + component);
       }
     } else {
       throw new IllegalArgumentException("Bad PhaseId:" + phaseId);
     }
   }
 }