1 16 package dlog4j.tags; 17 18 import java.sql.SQLException ; 19 import java.util.ArrayList ; 20 import java.util.List ; 21 22 import javax.servlet.http.HttpServletRequest ; 23 import javax.servlet.jsp.JspException ; 24 25 import net.sf.hibernate.HibernateException; 26 import net.sf.hibernate.Session; 27 import dlog4j.ReplyManager; 28 import dlog4j.SiteManager; 29 import dlog4j.formbean.SiteForm; 30 import dlog4j.formbean.UserForm; 31 32 36 public class TopCommentTag extends DlogBaseTag { 37 38 int count = 10; 39 40 public int doEndTag() throws JspException { 41 release(); 42 return EVAL_PAGE; 43 } 44 public void release() { 45 count = 10; 46 } 47 50 public int doStartTag() throws JspException { 51 if (pageContext.getAttribute(id) == null) { 52 Session session = null; 53 List replies = null; 54 try { 55 session = getSession(); 56 SiteForm site = SiteManager.getCurrentSite(pageContext.getRequest()); 57 UserForm loginUser = UserForm.getLoginUser((HttpServletRequest )pageContext.getRequest()); 58 replies = ReplyManager.listReplies(session, site, loginUser, count); 59 } catch (SQLException e) { 60 throw new JspException (e); 61 } catch (HibernateException e) { 62 throw new JspException (e); 63 } finally { 64 try { 65 closeSession(session); 66 } catch (Exception e) {} 67 } 68 if (replies == null) 69 replies = new ArrayList (); 70 pageContext.setAttribute(id, replies); 71 } 72 return SKIP_BODY; 73 } 74 75 78 public int getCount() { 79 return count; 80 } 81 82 85 public void setCount(int i) { 86 count = i; 87 } 88 89 92 public void setCount(Integer i) { 93 count = i.intValue(); 94 } 95 96 99 public void setCount(String i) { 100 count = Integer.parseInt(i); 101 } 102 103 } 104 | Popular Tags |