예제 #1
0
  // Process the components specified in the phaseClientIds list
  private void processComponents(
      UIComponent component,
      PhaseId phaseId,
      Collection<String> phaseClientIds,
      FacesContext context)
      throws IOException {

    // We use the tree visitor mechanism to locate the components to
    // process.  Create our (partial) VisitContext and the
    // VisitCallback that will be invoked for each component that
    // is visited.  Note that we use the SKIP_UNRENDERED hint as we
    // only want to visit the rendered subtree.
    EnumSet<VisitHint> hints = EnumSet.of(VisitHint.SKIP_UNRENDERED, VisitHint.EXECUTE_LIFECYCLE);
    PartialVisitContext visitContext = new PartialVisitContext(context, phaseClientIds, hints);
    PhaseAwareVisitCallback visitCallback = new PhaseAwareVisitCallback(ctx, phaseId);
    component.visitTree(visitContext, visitCallback);
    if (LOGGER.isLoggable(Level.FINER) && !visitContext.getUnvisitedClientIds().isEmpty()) {
      Collection<String> unvisitedClientIds = visitContext.getUnvisitedClientIds();
      String message;
      StringBuilder builder = new StringBuilder();
      for (String cur : unvisitedClientIds) {
        builder.append(cur).append(" ");
      }
      LOGGER.log(
          Level.FINER,
          "jsf.context.partial_visit_context_unvisited_children",
          new Object[] {builder.toString()});
    }
  }
예제 #2
0
  // Process the components specified in the phaseClientIds list
  private void processComponents(
      UIComponent component,
      PhaseId phaseId,
      Collection<String> phaseClientIds,
      FacesContext context)
      throws IOException {

    // We use the tree visitor mechanism to locate the components to
    // process.  Create our (partial) VisitContext and the
    // VisitCallback that will be invoked for each component that
    // is visited.  Note that we use the SKIP_UNRENDERED hint as we
    // only want to visit the rendered subtree.
    EnumSet<VisitHint> hints = EnumSet.of(VisitHint.SKIP_UNRENDERED);
    PartialVisitContext visitContext = new PartialVisitContext(context, phaseClientIds, hints);
    PhaseAwareVisitCallback visitCallback = new PhaseAwareVisitCallback(ctx, phaseId);
    component.visitTree(visitContext, visitCallback);
  }
  private boolean visitMetaComponent(
      String name, ExtendedVisitContext visitContext, VisitCallback callback) {
    UIComponent facet = getFacet(name);
    if (facet != null) {
      VisitResult result = visitContext.invokeMetaComponentVisitCallback(this, callback, name);

      if (result == VisitResult.ACCEPT) {
        if (facet.visitTree(visitContext, callback)) {
          result = VisitResult.COMPLETE;
        }
      }

      return result == VisitResult.COMPLETE;
    } else {
      return false;
    }
  }
  public DataVisitResult process(FacesContext context, Integer rowKey) {
    childrenTreeDataVisitorCallback.setRowKey(context, rowKey);

    if (childrenTreeDataVisitorCallback.isRowAvailable()) {
      final Iterator<UIComponent> componentIterator =
          childrenTreeDataVisitorCallback.dataChildren();

      while (componentIterator.hasNext()) {
        final UIComponent dataChild = componentIterator.next();

        if (dataChild.visitTree(visitContext, callback)) {
          visitResult = true;

          return DataVisitResult.STOP;
        }
      }
    }

    return DataVisitResult.CONTINUE;
  }
  protected boolean visitDataChildren(VisitContext visitContext, VisitCallback callback) {
    int rowIndex = 0;

    for (setRowIndex(rowIndex); isRowAvailable(); setRowIndex(++rowIndex)) {
      VisitResult result = visitContext.invokeVisitCallback(this, callback);

      if (result == VisitResult.COMPLETE) {
        return true;
      }

      if (result == VisitResult.REJECT) {
        continue;
      }

      for (UIComponent child : getChildren()) {
        if (child.visitTree(visitContext, callback)) {
          return true;
        }
      }
    }

    return false;
  }
  protected boolean visitFixedChildren(VisitContext visitContext, VisitCallback callback) {

    if (visitContext instanceof ExtendedVisitContext) {
      ExtendedVisitContext extendedVisitContext = (ExtendedVisitContext) visitContext;

      if (visitMetaComponent("header", extendedVisitContext, callback)) {
        return true;
      }

      if (visitMetaComponent("footer", extendedVisitContext, callback)) {
        return true;
      }

      return false;
    } else {
      for (UIComponent facet : getFacets().values()) {
        if (facet.visitTree(visitContext, callback)) {
          return true;
        }
      }

      return false;
    }
  }