1 16 package dlog4j.tags; 17 18 import javax.servlet.jsp.JspException ; 19 20 import net.sf.hibernate.HibernateException; 21 import net.sf.hibernate.Session; 22 import dlog4j.SiteManager; 23 import dlog4j.UserManager; 24 import dlog4j.formbean.UserForm; 25 26 29 public class UserTag extends DlogBaseTag { 30 31 int userid = -1; 32 33 String detail = "false"; 34 35 String loginName = null; 36 37 42 public int doStartTag() throws JspException { 43 if (loginName != null) { 44 Session ssn = null; 45 try { 46 ssn = getSession(); 47 UserForm user = UserManager.getUser(ssn, SiteManager 48 .getCurrentSite(pageContext.getRequest()), loginName); 49 50 if (user != null) 51 pageContext.setAttribute(id, user); 52 } catch (HibernateException e) { 53 throw new JspException (e); 54 } catch (Exception e) { 55 throw new JspException (e); 56 } finally { 57 try { 58 closeSession(ssn); 59 } catch (Exception e) { 60 } 61 } 62 } else { 63 int uid = userid; 64 if (uid == -1) 65 try { 66 uid = Integer.parseInt(pageContext.getRequest() 67 .getParameter("userid")); 68 } catch (Exception e) { 69 } 70 if (uid > -1) { 71 Session ssn = null; 72 try { 73 ssn = getSession(); 74 boolean bDetail = "true".equalsIgnoreCase(detail); 75 UserForm user = UserManager.getUser(ssn, uid, bDetail); 76 if (user != null) 77 pageContext.setAttribute(id, user); 78 } catch (HibernateException e) { 79 throw new JspException (e); 80 } catch (Exception e) { 81 throw new JspException (e); 82 } finally { 83 try { 84 closeSession(ssn); 85 } catch (Exception e) { 86 } 87 } 88 } 89 } 90 return SKIP_BODY; 91 } 92 93 public int doEndTag() throws JspException { 94 release(); 95 return EVAL_PAGE; 96 } 97 98 public void release() { 99 userid = -1; 100 detail = "false"; 101 } 102 103 106 public String getDetail() { 107 return detail; 108 } 109 110 113 public void setDetail(String string) { 114 detail = string; 115 } 116 117 120 public int getUserid() { 121 return userid; 122 } 123 124 127 public void setUserid(int i) { 128 userid = i; 129 } 130 131 134 public void setUserid(Integer i) { 135 userid = i.intValue(); 136 } 137 138 141 public void setUserid(String i) { 142 userid = Integer.parseInt(i); 143 } 144 145 public String getLoginName() { 146 return loginName; 147 } 148 149 public void setLoginName(String loginName) { 150 this.loginName = loginName; 151 } 152 } | Popular Tags |