KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > wcf > param > ParamLinkGroupTag


1 /*
2  * ====================================================================
3  * This software is subject to the terms of the Common Public License
4  * Agreement, available at the following URL:
5  * http://www.opensource.org/licenses/cpl.html .
6  * Copyright (C) 2003-2004 TONBELLER AG.
7  * All Rights Reserved.
8  * You must accept the terms of that agreement to use this software.
9  * ====================================================================
10  *
11  *
12  */

13 package com.tonbeller.wcf.param;
14
15 import javax.servlet.http.HttpServletRequest JavaDoc;
16 import javax.servlet.http.HttpSession JavaDoc;
17 import javax.servlet.jsp.JspException JavaDoc;
18 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
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 /**
27  * Groups several ParamLink Tags. When the start tag is executed,
28  * the SqlSessionParam cache is cleared. Then new SqlSessionParam instances
29  * are created by nested ParamLink tags.
30  *
31  * @author av
32  */

33 public class ParamLinkGroupTag extends TagSupport JavaDoc {
34   boolean renderActions;
35   String JavaDoc hideIf;
36
37   public int doStartTag() throws JspException JavaDoc {
38     getDispatcher().clear();
39     HttpServletRequest JavaDoc hsr = (HttpServletRequest JavaDoc) 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 JavaDoc obj = hideIf;
50     if (ExprUtils.isExpression(hideIf))
51       obj =ExprUtils.getModelReference(pageContext, hideIf);
52     if (obj instanceof Boolean JavaDoc)
53       return ((Boolean JavaDoc)obj).booleanValue();
54     if (obj instanceof String JavaDoc)
55       return Boolean.valueOf((String JavaDoc)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 JavaDoc 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 JavaDoc hideIf) {
75     this.hideIf = hideIf;
76   }
77 }
78
Popular Tags