1 53 54 106 107 package com.Yasna.forum.tags; 108 109 import java.io.*; 110 import java.util.*; 111 import java.text.*; 112 import javax.servlet.*; 113 import javax.servlet.jsp.*; 114 import javax.servlet.jsp.tagext.*; 115 import javax.servlet.http.*; 116 import com.Yasna.forum.*; 117 import com.Yasna.forum.tags.*; 118 119 162 public class ErrorLoopTag extends BodyTagSupport 163 { 164 private YazdRequest jr = null; 165 private List errorlist = null; 166 private Iterator errors = null; 167 private int index = 0; 168 169 174 public final int doStartTag() throws JspException 175 { 176 jr = (YazdRequest)pageContext.getAttribute("yazdUserRequest", 178 PageContext.REQUEST_SCOPE); 179 if( jr == null ) 180 throw new JspException("Could not find request"); 181 182 errorlist = jr.getErrorList(); 184 errors = errorlist.iterator(); 185 if( !errors.hasNext() ) 186 return SKIP_BODY; 187 188 pageContext.setAttribute(id,this,PageContext.PAGE_SCOPE); 190 return EVAL_BODY_TAG; 191 } 192 193 198 public final int doAfterBody() throws JspException 199 { 200 errors.next(); 202 if( !errors.hasNext() ) 204 return SKIP_BODY; 205 index++; 207 return EVAL_BODY_TAG; 208 } 209 210 214 public final int doEndTag() throws JspException 215 { 216 try 217 { 218 if(bodyContent != null) 219 bodyContent.writeOut(bodyContent.getEnclosingWriter()); 220 } catch(java.io.IOException e) 221 { 222 throw new JspException("IO Error: " + e.getMessage()); 223 } 224 return EVAL_PAGE; 225 } 226 227 233 public final String getError() 234 { 235 StringBuffer next = (StringBuffer )errorlist.get(index); 236 return next.toString(); 237 } 238 239 } 240 | Popular Tags |