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 158 public class MessageTag extends TagSupport implements YazdProperty, 159 NewMessages 160 { 161 private YazdState js = null; 162 private YazdRequest jr = null; 163 private ForumMessage cm = null; 164 private GetNestedMessage gnm = null; 165 private boolean nested = false; 167 168 173 public final int doStartTag() throws JspException 174 { 175 js = (YazdState)pageContext.getAttribute("yazdUserState", 177 PageContext.SESSION_SCOPE); 178 if( js == null ) { 179 throw new JspException("Yazd message tag could not get yazd state."); 180 } 181 182 jr = (YazdRequest)pageContext.getAttribute("yazdUserRequest", 184 PageContext.REQUEST_SCOPE); 185 if( jr == null ) 186 throw new JspException("Yazd message tag, could not find request"); 187 188 if( !nested ) { 190 cm = jr.getMessage(); 192 } else { 193 try { 195 gnm = (GetNestedMessage)this.findAncestorWithClass(this, 196 Class.forName("com.Yasna.forum.tags.GetNestedMessage")); 197 cm = gnm.getMessage(); 198 } catch(Exception e) { 199 } 200 } 201 202 if( cm == null ) 203 return SKIP_BODY; 204 205 pageContext.setAttribute(id,this,PageContext.PAGE_SCOPE); 207 return EVAL_BODY_INCLUDE; 208 } 209 210 214 public final void setNested(String a) 215 { 216 if( a.equals("true") )nested=true; 217 } 218 219 225 public final User getUser() 226 { 227 return cm.getUser(); 228 } 229 230 236 public final String getMessageid() 237 { 238 return "" + cm.getID(); 239 } 240 241 247 public final String getBody() 248 { 249 return cm.getBody(); 250 } 251 252 258 public final String getSubject() 259 { 260 return cm.getSubject(); 261 } 262 263 270 public final String getCreationDate() 271 { 272 return "" + cm.getCreationDate().getTime(); 273 } 274 275 282 public final String getModifiedDate() 283 { 284 return "" + cm.getModifiedDate().getTime(); 285 } 286 287 292 public final String getMessagecount() 293 { 294 if( gnm != null ) { 295 return "" + gnm.getTotal(); 296 } 297 return ""; 298 } 299 300 305 public final String getThreadid() 306 { 307 return "" + cm.getForumThread().getID(); 308 } 309 310 316 public final String getProperty(String name) 317 { 318 String tmp = cm.getProperty(name); 319 if( tmp != null )return tmp; 320 return ""; 321 } 322 323 327 public final void setProperty(String name, String value) 328 { 329 cm.setProperty(name,value); 330 } 331 332 337 public final boolean newMessages() 338 { 339 if( js.getLastForumVisitDate(cm.getForumThread().getForum(),jr).getTime() < 340 cm.getModifiedDate().getTime() ) 341 return true; 342 return false; 343 } 344 345 350 public final boolean isAnonymous() 351 { 352 return cm.isAnonymous(); 353 } 354 355 358 public final void release() 359 { 360 if( id != null && id.length() > 0 ) 361 pageContext.removeAttribute(id,PageContext.PAGE_SCOPE); 362 } 363 364 public final int getReplyPrivateUserId() 365 { 366 return cm.getReplyPrivateUserId(); 367 } 368 369 public boolean isPrivate() { 370 return cm.isPrivate(); 371 } 372 373 public final boolean isApproved() 374 { 375 return cm.isApproved(); 376 } 377 378 } 379 | Popular Tags |