1 53 54 106 107 package com.Yasna.forum.tags; 108 109 import java.io.*; 110 import javax.servlet.*; 111 import javax.servlet.jsp.*; 112 import javax.servlet.jsp.tagext.*; 113 import javax.servlet.http.*; 114 import com.Yasna.forum.*; 115 import com.Yasna.forum.tags.*; 116 117 145 146 public class ChangeForumTag extends BodyTagSupport 147 { 148 private YazdRequest jr = null; 149 150 155 public final int doStartTag() throws JspException 156 { 157 return EVAL_BODY_TAG; 158 } 159 160 166 public final int doAfterBody() throws JspException 167 { 168 jr = (YazdRequest)pageContext.getAttribute("yazdUserRequest", 170 PageContext.REQUEST_SCOPE); 171 if( jr == null ) 172 throw new JspException("Yazd change_forum tag, could not find request"); 173 174 BodyContent body = getBodyContent(); 176 String s = body.getString(); 177 body.clearBody(); 179 180 int fid = 0; 181 try { 182 fid = Integer.valueOf(s).intValue(); 183 } catch(NumberFormatException e) { 184 throw new JspException( 185 "Yazd change_forum tag, body of tag is not a forumID integer"); 186 } 187 188 Forum pf = null; 190 try { 191 pf = jr.getForumFactory().getForum(fid); 192 } catch(Exception e) { 193 throw new JspException( 194 "Yazd change_forum tag, could not find forum with ID: " + fid); 195 } 196 197 if( pf == null ) { 198 throw new JspException( 199 "Yazd change_forum tag, could not find forum with ID: " + fid); 200 } 201 202 ChangeForum sfi = null; 204 try { 205 sfi = (ChangeForum)this.findAncestorWithClass(this, 206 Class.forName("com.Yasna.forum.tags.ChangeForum")); 207 } catch(Exception e) { 208 } 209 210 if( sfi == null ) { 212 throw new JspException( 213 "Yazd change_forum tag must be nested inside a post or move tag"); 214 } 215 sfi.changeForum(pf); 216 217 return SKIP_BODY; 218 } 219 220 } 221 | Popular Tags |