KickJava   Java API By Example, From Geeks To Geeks.

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


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="treeNameRenderer" body-content="empty"
23  */

24 public class TreeNameRendererTag 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 display = 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          display = renderer.getDisplayName(o);
67       }
68       catch (Exception JavaDoc e)
69       {
70          display = null;
71       }
72       if (display == null)
73       {
74          display = "";
75       }
76
77       ResponseUtils.write(pageContext, display);
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
133    /** Release all allocated resources. */
134    public void release()
135    {
136       super.release();
137       scope = null;
138       className = null;
139       property = null;
140       name = null;
141    }
142
143
144    /**
145     * Sets the name attribute of the TreeSpacerTag object
146     *
147     * @param name The new name value
148     */

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

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

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

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