1 53 54 106 107 package com.Yasna.forum.tags; 108 109 import java.io.*; 110 import java.util.*; 111 import javax.servlet.*; 112 import javax.servlet.jsp.*; 113 import javax.servlet.jsp.tagext.*; 114 import javax.servlet.http.*; 115 import com.Yasna.forum.*; 116 import com.Yasna.forum.tags.*; 117 118 167 public class ForEachTag extends BodyTagSupport 168 { 169 private int begin = 0; 170 private int end = 0; 171 private int index = 0; 172 private int step = 1; 173 174 179 public final int doStartTag() throws JspException 180 { 181 pageContext.setAttribute(id,this,PageContext.PAGE_SCOPE); 183 if( index > end ) 184 return SKIP_BODY; 185 return EVAL_BODY_TAG; 186 } 187 188 193 public final int doAfterBody() throws JspException 194 { 195 index += step; 196 if( index > end ) 197 return SKIP_BODY; 198 return EVAL_BODY_TAG; 199 } 200 201 205 public final int doEndTag() throws JspException 206 { 207 try 208 { 209 if(bodyContent != null) 210 bodyContent.writeOut(bodyContent.getEnclosingWriter()); 211 } catch(java.io.IOException e) 212 { 213 throw new JspException("IO Error: " + e.getMessage()); 214 } 215 return EVAL_PAGE; 216 } 217 218 221 public final void setBegin(String beg) 222 { 223 index = begin = Integer.valueOf(beg).intValue(); 224 } 225 226 229 public final void setEnd(String last) 230 { 231 end = Integer.valueOf(last).intValue(); 232 } 233 234 237 public final void setStep(String last) 238 { 239 step = Integer.valueOf(last).intValue(); 240 } 241 242 248 public final String getValue() 249 { 250 return "" + index; 251 } 252 253 256 public final void release() 257 { 258 if( id != null && id.length() > 0 ) 259 pageContext.removeAttribute(id,PageContext.PAGE_SCOPE); 260 } 261 262 } 263 | Popular Tags |