Java源码示例:javax.faces.component.visit.VisitCallback

示例1
private boolean visitChildren(VisitContext context, VisitCallback callback) {
	Integer begin = this.getBegin();
	Integer end = this.getEnd();
	Integer step = this.getStep();

	int rowCount = getDataModel().getRowCount();
	int i = ((begin != null) ? begin : 0);
	int e = ((end != null) ? end : rowCount);
	int s = ((step != null) ? step : 1);
	validateIterationControlValues(rowCount, i, e);
	FacesContext faces = context.getFacesContext();
	this.setIndex(faces, i);
	this.updateIterationStatus(faces, new IterationStatus(true, (i + s > e || rowCount == 1), i, begin, end, step));
	while (i < e && this.isIndexAvailable()) {

		this.setIndex(faces, i);
		this.updateIterationStatus(faces, new IterationStatus(false, i + s >= e, i, begin, end, step));
		for (UIComponent kid : getChildren()) {
			if (kid.visitTree(context, callback)) {
				return true;
			}
		}
		i += s;
	}

	return false;
}
 
示例2
@Override
  public boolean visitTree(VisitContext context, VisitCallback callback) {
if (!isVisitable(context)) {
	return false;
}
// Check for the current component
VisitResult res = context.invokeVisitCallback(this, callback);
if (res == VisitResult.COMPLETE) return true;
if (res == VisitResult.ACCEPT) {
	// we should visit the children if we have ids (all or selected) to visit
	boolean visitChildren = !context.getSubtreeIdsToVisit(this).isEmpty();
	if (visitChildren) {
		// visit the component facets
    	UIComponent facet = selectFacet(); 
    	if(facet!=null) {
    		try {
    			if(facet.visitTree(context, callback)) {
					return true;
        		}
    		} finally {
            	unselectFacet();
    		}
        }
	}
}
  	return false;
  }
 
示例3
@Override
public boolean visitTree(VisitContext context, VisitCallback callback) {
    try { 
        _shadowedData = publishControlData(context.getFacesContext());
        return super.visitTree(context, callback);
    } finally {
        revokeControlData(_shadowedData, context.getFacesContext());
        _shadowedData = null;
    }
}
 
示例4
@Override
public boolean visitTree(VisitContext context, VisitCallback callback) {

	if (this.getVar() == null) {
		return super.visitTree(context, callback);
	}

	// First check to see whether we are visitable. If not
	// short-circuit out of this subtree, though allow the
	// visit to proceed through to other subtrees.
	if (!isVisitable(context)) {
		return false;
	}

	FacesContext facesContext = context.getFacesContext();
	boolean visitRows = requiresRowIteration(context);

	int oldRowIndex = -1;
	if (visitRows) {
		oldRowIndex = getDataModel().getRowIndex();
		setIndex(facesContext, -1);
	}

	this.setDataModel(null);

	// Push ourselves to EL
	pushComponentToEL(facesContext, null);

	try {

		// Visit ourselves. Note that we delegate to the
		// VisitContext to actually perform the visit.
		VisitResult result = context.invokeVisitCallback(this, callback);

		// If the visit is complete, short-circuit out and end the visit
		if (result == VisitResult.COMPLETE) {
			return true;
		}

		// Visit children, short-circuiting as necessary
		if ((result == VisitResult.ACCEPT) && doVisitChildren(context)) {

			// And finally, visit rows
			if (!visitRows) {
				// visit rows without model access
				for (UIComponent kid : getChildren()) {
					if (kid.visitTree(context, callback)) {
						return true;
					}
				}
			} else {
				if (visitChildren(context, callback)) {
					return true;
				}
			}
		}
	} finally {
		// Clean up - pop EL and restore old row index
		popComponentFromEL(facesContext);
		if (visitRows) {
			setIndex(facesContext, oldRowIndex);
		}
	}

	// Return false to allow the visit to continue
	return false;
}