KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Description of the Class
17  *
18  * @author Laurent Etiemble
19  * @version $Revision: 1.1 $
20  * @todo Javadoc to complete
21  * @jsp:tag name="treeSpacer" body-content="empty"
22  */

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

41    public int doStartTag()
42       throws JspException JavaDoc
43    {
44       String JavaDoc img = null;
45       String JavaDoc follow = getValue();
46
47       if (follow == null)
48       {
49          if (name == null)
50          {
51             return (SKIP_BODY);
52          }
53          if (property != null)
54          {
55             follow = (String JavaDoc) RequestUtils.lookup(pageContext, name, property, scope);
56          }
57          else
58          {
59             follow = (String JavaDoc) RequestUtils.lookup(pageContext, name, scope);
60          }
61       }
62
63       if (follow.length() <= 0)
64       {
65          return (SKIP_BODY);
66       }
67
68       StringBuffer JavaDoc output = new StringBuffer JavaDoc();
69
70       for (int i = 0; i < follow.length(); i++)
71       {
72          if ("1".equals(follow.substring(i, i + 1)))
73          {
74             img = "<img SRC=\"images/tree/line.gif\"/>";
75          }
76          else
77          {
78             img = "<img SRC=\"images/tree/empty.gif\"/>";
79          }
80          output.append(img);
81       }
82
83       ResponseUtils.write(pageContext, output.toString());
84
85       // Continue processing this page
86
return (SKIP_BODY);
87    }
88
89
90    /**
91     * Gets the name attribute of the TreeSpacerTag object
92     *
93     * @return The name value
94     * @jsp:attribute name="name" required="false" rtexprvalue="true"
95     */

96    public String JavaDoc getName()
97    {
98       return (this.name);
99    }
100
101
102    /**
103     * Gets the property attribute of the TreeSpacerTag object
104     *
105     * @return The property value
106     * @jsp:attribute name="property" required="false" rtexprvalue="true"
107     */

108    public String JavaDoc getProperty()
109    {
110       return (this.property);
111    }
112
113
114    /**
115     * Gets the scope attribute of the TreeSpacerTag object
116     *
117     * @return The scope value
118     * @jsp:attribute name="scope" required="false" rtexprvalue="true"
119     */

120    public String JavaDoc getScope()
121    {
122       return (this.scope);
123    }
124
125
126    /**
127     * Gets the follow attribute of the TreeSpacerTag object
128     *
129     * @return The follow value
130     * @jsp:attribute name="value" required="false" rtexprvalue="true"
131     */

132    public String JavaDoc getValue()
133    {
134       return (this.value);
135    }
136
137
138
139    /** Release all allocated resources. */
140    public void release()
141    {
142       super.release();
143       value = null;
144    }
145
146
147    /**
148     * Sets the name attribute of the TreeSpacerTag object
149     *
150     * @param name The new name value
151     */

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

163    public void setProperty(String JavaDoc property)
164    {
165       this.property = property;
166    }
167
168
169    /**
170     * Sets the scope attribute of the TreeSpacerTag object
171     *
172     * @param scope The new scope value
173     */

174    public void setScope(String JavaDoc scope)
175    {
176       this.scope = scope;
177    }
178
179
180    /**
181     * Sets the follow attribute of the TreeSpacerTag object
182     *
183     * @param value The new value value
184     */

185    public void setValue(String JavaDoc value)
186    {
187       this.value = value;
188    }
189
190 }
191
192
Popular Tags