1 13 package com.tonbeller.wcf.param; 14 15 import javax.servlet.http.HttpServletRequest ; 16 import javax.servlet.http.HttpSession ; 17 import javax.servlet.jsp.JspException ; 18 import javax.servlet.jsp.tagext.TagSupport ; 19 20 import com.tonbeller.wcf.component.RendererParameters; 21 import com.tonbeller.wcf.controller.Controller; 22 import com.tonbeller.wcf.controller.Dispatcher; 23 import com.tonbeller.wcf.controller.DispatcherSupport; 24 import com.tonbeller.wcf.expr.ExprUtils; 25 26 33 public class ParamLinkGroupTag extends TagSupport { 34 boolean renderActions; 35 String hideIf; 36 37 public int doStartTag() throws JspException { 38 getDispatcher().clear(); 39 HttpServletRequest hsr = (HttpServletRequest ) pageContext.getRequest(); 40 renderActions = RendererParameters.isRenderActions(hsr); 41 if (renderActions) 42 renderActions = !isHideLinks(); 43 return EVAL_BODY_INCLUDE; 44 } 45 46 private boolean isHideLinks() { 47 if (hideIf == null) 48 return false; 49 Object obj = hideIf; 50 if (ExprUtils.isExpression(hideIf)) 51 obj =ExprUtils.getModelReference(pageContext, hideIf); 52 if (obj instanceof Boolean ) 53 return ((Boolean )obj).booleanValue(); 54 if (obj instanceof String ) 55 return Boolean.valueOf((String )obj).booleanValue(); 56 return false; 57 } 58 59 Dispatcher getDispatcher() { 60 Dispatcher d = (Dispatcher) pageContext.getSession().getAttribute(id); 61 if (d == null) { 62 d = new DispatcherSupport(); 63 HttpSession session = pageContext.getSession(); 64 session.setAttribute(id, d); 65 Controller.instance(session).addRequestListener(d); 66 } 67 return d; 68 } 69 70 public boolean isRenderActions() { 71 return renderActions; 72 } 73 74 public void setHideIf(String hideIf) { 75 this.hideIf = hideIf; 76 } 77 } 78 | Popular Tags |