Java 类javax.servlet.jsp.jstl.core.LoopTagStatus 实例源码

项目:helium    文件:TascaFormValidatorHelper.java   
public static String getErrorField(Errors errors, TascaDadaDto dada, LoopTagStatus index) {
    try {
        FieldError fieldError = errors.getFieldError(dada.getVarCodi() + "[" + index.getIndex()  + "]");
        return fieldError.getCode();
    } catch (Exception ex) {
        return null;
    }
}
项目:Runway-SDK    文件:ComponentsTagSupport.java   
@AttributeAnnotation(required=true, description="The name of the servlet parameter")
public String getParam()
{
  LoopTagStatus stat = this.getLoopStatus();
  int c = stat.getCount() - 1;

  return param + "_" + c;
}
项目:Runway-SDK    文件:ComponentsTagSupport.java   
@Override
protected void invokeBody() throws JspException, IOException
{
  JspWriter out = this.getJspContext().getOut();

  LoopTagStatus stat = this.getLoopStatus();
  MutableDTO item = (MutableDTO) stat.getCurrent();

  ComponentTagSupport.doComponent(out, this.getParam(), item);

  if(this.getJspBody() != null)
  {
    this.getJspBody().invoke(null);
  }
}
项目:fauxjsp    文件:JstlCoreTaglibForEach.java   
@Override
protected void renderNode(RenderSession session, JspTaglibInvocation invocation) {
    String itemsExpression = getAttribute("items", invocation);
    String varName = getAttribute("var", invocation);
    String sBegin = getAttribute("begin", invocation);
    String sEnd = getAttribute("end", invocation);
    String sStep = getAttribute("step", invocation);
    String varStatus = getAttribute("varStatus", invocation);
    int begin = 0;
    int end = 0;
    int step = 1;

    Object rawItems = evaluate(itemsExpression, session);
    if (rawItems == null)
        error(itemsExpression + " is null", invocation);
    if (!(rawItems instanceof Collection) && !(rawItems.getClass().isArray()))
        error("items attribute is neither a collection nor an array, but " + rawItems, invocation);
    List<Object> items = toList(rawItems);
    if (!Utils.isEmpty(sBegin))
        begin = Utils.evalToInt(sBegin, session);
    if (!Utils.isEmpty(sEnd))
        end = Utils.evalToInt(sEnd, session) + 1;
    else
        end = items.size();
    if (!Utils.isEmpty(sStep))
        step = Utils.evalToInt(sStep, session);

    for (int i = begin, count = 1; i < end; i = i + step, count++) {
        Object item = items.get(i);
        session.request.setAttribute(varName, item);
        if (!Utils.isEmpty(varStatus)) {
            Integer _begin = Utils.isEmpty(sBegin) ? null : begin;
            Integer _end = Utils.isEmpty(sEnd) ? null : end;
            Integer _step = Utils.isEmpty(sStep) ? null : step;
            boolean isFirst = count == 1;
            boolean isLast = i + step >= end;
            LoopTagStatus lts = new ForEachIndex(item, i, count, _begin, _end, _step, isFirst, isLast);
            session.request.setAttribute(varStatus, lts);
        }
        for (JspNode child : invocation.getChildren())
            session.renderer.render(child, session);
    }
}
项目:Runway-SDK    文件:ListTagSupport.java   
public LoopTagStatus getLoopStatus()
{
  class Status implements LoopTagStatus
  {
    public Integer getBegin()
    {
      return begin;
    }

    public int getCount()
    {
      return count;
    }

    public Object getCurrent()
    {
      return current;
    }

    public Integer getEnd()
    {
      return end;
    }

    public int getIndex()
    {
      return begin + index;
    }

    public Integer getStep()
    {
      return step;
    }

    public boolean isFirst()
    {
      return ( index == begin );
    }

    public boolean isLast()
    {
      return ( index == end - 1 );
    }
  }

  if (status == null)
  {
    status = new Status();
  }

  return status;
}
项目:Runway-SDK    文件:ListElementTagSupport.java   
public LoopTagStatus getLoopStatus()
{
  class Status implements LoopTagStatus
  {
    public Integer getBegin()
    {
      return begin;
    }

    public int getCount()
    {
      return count;
    }

    public Object getCurrent()
    {
      return current;
    }

    public Integer getEnd()
    {
      return end;
    }

    public int getIndex()
    {
      return begin + index;
    }

    public Integer getStep()
    {
      return step;
    }

    public boolean isFirst()
    {
      return ( index == begin );
    }

    public boolean isLast()
    {
      return ( index == end - 1 );
    }
  }

  if (status == null)
  {
    status = new Status();
  }

  return status;
}