Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Custom Tag Iterator is so slow.  RSS feed

 
Dmitriy Pavlyuk
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Say me, please, why the custom tag which iterate the collection works so slow with big tag content. It works 5 second where the for ... construction works 1 second.
My system is Win2000 professional, jdk1.3, Resin 1.2.3.
This trouble appears also in jakarta "forEach" tag and in struts "iterate" tag.
My tag's code source is
public final class IterateTag extends BodyTagSupport {
private String id = null;
private Iterator iterator = null;
public String getId() {
return (this.id);
}
public void setId(String id) {
this.id = id;
}

public Iterator getIterator() {
return (this.iterator);
}
public void setIterator(Iterator it) {
this.iterator = it;
}

public int doStartTag() throws JspException {
if (iterator.hasNext()) {
pageContext.setAttribute(id, iterator.next());
return EVAL_BODY_TAG;
} else
return SKIP_BODY;
}

public int doAfterBody() throws JspException {
if (iterator.hasNext()) {
pageContext.setAttribute(id, iterator.next());
return EVAL_BODY_TAG;
} else
return SKIP_BODY;
}
public int doEndTag() throws JspException {
if (bodyContent != null) {
try {
JspWriter out = getPreviousOut();
out.print(bodyContent.getString());
} catch (IOException e) {
throw new JspException("End Error");
}
}
return EVAL_PAGE;
}

public void release() {
super.release();
id = null;
iterator = null;
}
}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!