1 16 package dlog4j.tags; 17 18 import javax.servlet.jsp.JspException ; 19 import javax.servlet.jsp.PageContext ; 20 21 import net.sf.hibernate.Session; 22 import dlog4j.formbean.MessageForm; 23 24 28 public class ReplyMessageTag extends DlogBaseTag { 29 30 String scope = "session"; 31 String msgid = null; 32 33 public int doStartTag() throws JspException { 34 int iScope = PageContext.SESSION_SCOPE; 35 if("request".equalsIgnoreCase(scope)) 36 iScope = PageContext.REQUEST_SCOPE; 37 MessageForm msgForm = (MessageForm)pageContext.getAttribute(id,iScope); 38 if(msgForm==null) { 39 int rid = -1; 40 try { 41 rid = Integer.parseInt(msgid); 42 }catch(Exception e) {} 43 if(rid == -1) { 44 try { 45 rid = Integer.parseInt(pageContext.getRequest().getParameter("msgid")); 46 }catch(Exception e) {} 47 } 48 if(rid!=-1) { 49 Session ssn = null; 50 try { 51 ssn = getSession(); 52 msgForm = (MessageForm)ssn.load(MessageForm.class,new Integer (rid)); 53 msgForm.setContent("<BR>----- Original Message -----<BR>"+msgForm.getContent()); 54 pageContext.setAttribute(id,msgForm,iScope); 55 } catch (Exception e) { 56 }finally { 57 try { 58 closeSession(ssn); 59 }catch(Exception e) {} 60 } 61 } 62 } 63 return SKIP_BODY; 64 } 65 public int doEndTag() throws JspException { 66 release(); 67 return EVAL_PAGE; 68 } 69 public void release() { 70 scope = "session"; 71 msgid = null; 72 } 73 public String getScope() { 74 return scope; 75 } 76 public void setScope(String scope) { 77 this.scope = scope; 78 } 79 public String getMsgid() { 80 return msgid; 81 } 82 public void setMsgid(String msgid) { 83 this.msgid = msgid; 84 } 85 } 86 | Popular Tags |