1 5 6 package com.raptus.owxv3.libtags; 7 8 import java.util.HashMap ; 9 10 import javax.servlet.http.*; 11 import javax.servlet.jsp.JspException ; 12 import javax.servlet.jsp.tagext.TagSupport ; 13 14 import com.raptus.owxv3.modules.base.BaseEntryCounter; 15 16 37 public class HasNoEntriesTag extends TagSupport 38 { 39 protected String vmodule; 40 private final String CACHE_SESS_ID="com.raptus.owxv3.HAS_NOENTRIES_CACHE"; 41 public void setVmodule(String v) 42 { 43 vmodule=v; 44 } 45 public String getVmodule() 46 { 47 return vmodule; 48 } 49 50 public int doStartTag() throws JspException 51 { 52 HttpServletRequest req=(HttpServletRequest) pageContext.getRequest(); 54 HttpSession session=req.getSession(); 55 HashMap cache=(HashMap )session.getAttribute(CACHE_SESS_ID); 56 Boolean b=null; 57 if(cache!=null) 58 { 59 b=(Boolean )cache.get(vmodule); 60 } 61 if(b==null) 62 { 63 int count=BaseEntryCounter.countActiveEntriesIn(vmodule); 65 if(count>0) 66 { 67 b=new Boolean (false); 68 } 69 else 70 { 71 b=new Boolean (true); 72 } 73 } 75 if(cache==null) 76 { 77 cache=new HashMap (); 78 } 79 cache.put(vmodule,b); 80 session.setAttribute(CACHE_SESS_ID,cache); 81 82 if(b.booleanValue()==true) 83 { 84 return (EVAL_BODY_INCLUDE); 85 } 86 else 87 { 88 return (SKIP_BODY); 89 } 90 91 } 93 94 99 public int doEndTag() throws JspException 100 { 101 return (EVAL_PAGE); 102 } 103 104 105 } | Popular Tags |