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.ReplyForm; 23 24 28 public class EditReplyTag extends DlogBaseTag { 29 30 String scope = "session"; 31 String replyId = 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 ReplyForm replyForm = (ReplyForm)pageContext.getAttribute(id,iScope); 38 if(replyForm==null) { 39 int rid = -1; 40 try { 41 rid = Integer.parseInt(replyId); 42 }catch(Exception e) {} 43 if(rid == -1) { 44 try { 45 rid = Integer.parseInt(pageContext.getRequest().getParameter("reply_id")); 46 }catch(Exception e) {} 47 } 48 if(rid!=-1) { 49 Session ssn = null; 50 try { 51 ssn = getSession(); 52 replyForm = (ReplyForm)ssn.load(ReplyForm.class,new Integer (rid)); 53 pageContext.setAttribute(id,replyForm,iScope); 54 } catch (Exception e) { 55 throw new JspException (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 replyId = null; 72 } 73 public String getScope() { 74 return scope; 75 } 76 public void setScope(String scope) { 77 this.scope = scope; 78 } 79 public String getReplyId() { 80 return replyId; 81 } 82 public void setReplyId(String replyId) { 83 this.replyId = replyId; 84 } 85 } 86 | Popular Tags |