KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejtools > servlet > http > jsp > tagext > tree > TreeIconRendererTag


1 /*
2  * EJTools, the Enterprise Java Tools
3  *
4  * Distributable under LGPL license.
5  * See terms of license at www.gnu.org.
6  */

7 package org.ejtools.servlet.http.jsp.tagext.tree;
8
9 import javax.servlet.jsp.JspException JavaDoc;
10 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
11
12 import org.apache.struts.util.RequestUtils;
13 import org.apache.struts.util.ResponseUtils;
14
15
16 /**
17  * Description of the Class
18  *
19  * @author Laurent Etiemble
20  * @version $Revision: 1.1 $
21  * @todo Javadoc to complete
22  * @jsp:tag name="treeIconRenderer" body-content="empty"
23  */

24 public class TreeIconRendererTag extends TagSupport JavaDoc
25 {
26    /** Description of the Field */
27    protected String JavaDoc className = null;
28    /** Description of the Field */
29    protected String JavaDoc name = null;
30    /** Description of the Field */
31    protected String JavaDoc property = null;
32    /** Description of the Field */
33    protected String JavaDoc scope = null;
34
35
36    /**
37     * Description of the Method
38     *
39     * @return Description of the Return Value
40     * @exception JspException Description of the Exception
41     */

42    public int doStartTag()
43       throws JspException JavaDoc
44    {
45       String JavaDoc img = null;
46       Object JavaDoc o = null;
47
48       if (property != null)
49       {
50          o = RequestUtils.lookup(pageContext, name, property, scope);
51       }
52       else
53       {
54          o = RequestUtils.lookup(pageContext, name, scope);
55       }
56
57       if (o == null)
58       {
59          return (SKIP_BODY);
60       }
61
62       try
63       {
64          TreeRenderer renderer = (TreeRenderer) Class.forName(this.className).newInstance();
65
66          img = renderer.getIcon(o);
67       }
68       catch (Exception JavaDoc e)
69       {
70          img = null;
71       }
72       if (img == null)
73       {
74          img = "";
75       }
76
77       ResponseUtils.write(pageContext, "<img SRC=\"" + img + "\"/>");
78
79       // Continue processing this page
80
return (SKIP_BODY);
81    }
82
83
84    /**
85     * Gets the name attribute of the TreeSpacerTag object
86     *
87     * @return The name value
88     * @jsp:attribute name="name" required="true" rtexprvalue="true"
89     */

90    public String JavaDoc getName()
91    {
92       return (this.name);
93    }
94
95
96    /**
97     * Gets the property attribute of the TreeRendererTag object
98     *
99     * @return The property value
100     * @jsp:attribute name="property" required="false" rtexprvalue="true"
101     */

102    public String JavaDoc getProperty()
103    {
104       return (this.property);
105    }
106
107
108    /**
109     * Gets the class attribute of the TreeRendererTag object
110     *
111     * @return The class value
112     * @jsp:attribute name="renderer" required="true" rtexprvalue="true"
113     */

114    public String JavaDoc getRenderer()
115    {
116       return (this.className);
117    }
118
119
120    /**
121     * Gets the scope attribute of the TreeSpacerTag object
122     *
123     * @return The scope value
124     * @jsp:attribute name="scope" required="false" rtexprvalue="true"
125     */

126    public String JavaDoc getScope()
127    {
128       return (this.scope);
129    }
130
131
132    /** Release all allocated resources. */
133    public void release()
134    {
135       super.release();
136       scope = null;
137       className = null;
138       property = null;
139       name = null;
140    }
141
142
143    /**
144     * Sets the name attribute of the TreeSpacerTag object
145     *
146     * @param name The new name value
147     */

148    public void setName(String JavaDoc name)
149    {
150       this.name = name;
151    }
152
153
154    /**
155     * Sets the property attribute of the TreeRendererTag object
156     *
157     * @param property The new property value
158     */

159    public void setProperty(String JavaDoc property)
160    {
161       this.property = property;
162    }
163
164
165    /**
166     * Sets the class attribute of the TreeRendererTag object
167     *
168     * @param className The new class value
169     */

170    public void setRenderer(String JavaDoc className)
171    {
172       this.className = className;
173    }
174
175
176    /**
177     * Sets the scope attribute of the TreeSpacerTag object
178     *
179     * @param scope The new scope value
180     */

181    public void setScope(String JavaDoc scope)
182    {
183       this.scope = scope;
184    }
185 }
186
Popular Tags