FileDocCategorySizeDatePackage
ForEachTag.javaAPI DocGlassfish v2 API6476Sat May 05 19:17:56 BST 2007org.apache.taglibs.standard.tag.el.core

ForEachTag

public class ForEachTag extends org.apache.taglibs.standard.tag.common.core.ForEachSupport implements javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.jstl.core.LoopTag

A handler for <forEach> that accepts attributes as Strings and evaluates them as expressions at runtime.

author
Shawn Bayern

Fields Summary
private String
begin_
private String
end_
private String
step_
private String
items_
Constructors Summary
public ForEachTag()

        super();
        init();
    
Methods Summary
public intdoStartTag()


        // evaluate any expressions we were passed, once per invocation
        evaluateExpressions();

	// chain to the parent implementation
	return super.doStartTag();
    
private voidevaluateExpressions()

        /* 
         * Note: we don't check for type mismatches here; we assume
         * the expression evaluator will return the expected type
         * (by virtue of knowledge we give it about what that type is).
         * A ClassCastException here is truly unexpected, so we let it
         * propagate up.
         */

        if (begin_ != null) {
            Object r = ExpressionEvaluatorManager.evaluate(
                "begin", begin_, Integer.class, this, pageContext);
	    if (r == null)
		throw new NullAttributeException("forEach", "begin");
            begin = ((Integer) r).intValue();
            validateBegin();
        }

        if (end_ != null) {
            Object r = ExpressionEvaluatorManager.evaluate(
                "end", end_, Integer.class, this, pageContext);
	    if (r == null)
		throw new NullAttributeException("forEach", "end");
            end = ((Integer) r).intValue();
            validateEnd();
        }

        if (step_ != null) {
            Object r = ExpressionEvaluatorManager.evaluate(
                "step", step_, Integer.class, this, pageContext);
	    if (r == null)
		throw new NullAttributeException("forEach", "step");
            step = ((Integer) r).intValue();
            validateStep();
        }

	if (items_ != null) {
            rawItems = ExpressionEvaluatorManager.evaluate(
                "items", items_, Object.class, this, pageContext);
	    // use an empty list to indicate "no iteration", if relevant
	    if (rawItems == null)
		rawItems = new ArrayList();
        }
    
private voidinit()

        // defaults for interface with page author
        begin_ = null;          // (no expression)
        end_ = null;            // (no expression)
        step_ = null;           // (no expression)
	items_ = null;		// (no expression)
    
public voidrelease()

        super.release();
        init();
    
public voidsetBegin(java.lang.String begin_)

        this.begin_ = begin_;
        this.beginSpecified = true;
    
public voidsetEnd(java.lang.String end_)

        this.end_ = end_;
        this.endSpecified = true;
    
public voidsetItems(java.lang.String items_)

        this.items_ = items_;
    
public voidsetStep(java.lang.String step_)

        this.step_ = step_;
        this.stepSpecified = true;