KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > albel > tags > table > ColumnHeaderTag


1 package albel.tags.table;
2
3 import albel.tags.table.controll.Manager;
4 import albel.tags.table.model.*;
5 import albel.tags.table.utils.HttpSessionAttributesMap;
6 import javax.servlet.http.HttpServletRequest JavaDoc;
7 import javax.servlet.jsp.JspException JavaDoc;
8 import javax.servlet.jsp.tagext.BodyTagSupport JavaDoc;
9
10
11 /**
12  * @author albel
13  *Column definition tag
14  */

15 public class ColumnHeaderTag extends BodyTagSupport JavaDoc
16 {
17     
18     /**
19      * Holds value of property title.
20      */

21     private String JavaDoc title;
22     
23     /**
24      * Holds value of property align.
25      */

26     private String JavaDoc align;
27     
28     /**
29      * Holds value of property cssClass.
30      */

31     private String JavaDoc cssClass;
32     
33     public ColumnHeaderTag()
34     {
35         super();
36     }
37     
38     ////////////////////////////////////////////////////////////////
39
/// ///
40
/// User methods. ///
41
/// ///
42
/// Modify these methods to customize your tag handler. ///
43
/// ///
44
////////////////////////////////////////////////////////////////
45

46     
47     //
48
// methods called from doStartTag()
49
//
50
/**
51      *
52      * Fill in this method to perform other operations from doStartTag().
53      *
54      */

55     public void otherDoStartTagOperations()
56     {
57         
58         //
59
// TODO: code that performs other operations in doStartTag
60
// should be placed here.
61
// It will be called after initializing variables,
62
// finding the parent, setting IDREFs, etc, and
63
// before calling theBodyShouldBeEvaluated().
64
//
65
// For example, to print something out to the JSP, use the following:
66
//
67
// try {
68
// JspWriter out = pageContext.getOut();
69
// out.println("something");
70
// } catch (java.io.IOException ex) {
71
// // do something
72
// }
73
//
74
//
75

76         
77     }
78     
79     /**
80      *
81      * Fill in this method to determine if the tag body should be evaluated
82      * Called from doStartTag().
83      *
84      */

85     public boolean theBodyShouldBeEvaluated()
86     {
87         
88         //
89
// TODO: code that determines whether the body should be
90
// evaluated should be placed here.
91
// Called from the doStartTag() method.
92
//
93
return true;
94         
95     }
96     
97     
98     //
99
// methods called from doEndTag()
100
//
101
/**
102      *
103      * Fill in this method to perform other operations from doEndTag().
104      *
105      */

106     public void otherDoEndTagOperations()
107     {
108         
109         //
110
// TODO: code that performs other operations in doEndTag
111
// should be placed here.
112
// It will be called after initializing variables,
113
// finding the parent, setting IDREFs, etc, and
114
// before calling shouldEvaluateRestOfPageAfterEndTag().
115
//
116

117         
118     }
119     
120     /**
121      *
122      * Fill in this method to determine if the rest of the JSP page
123      * should be generated after this tag is finished.
124      * Called from doEndTag().
125      *
126      */

127     public boolean shouldEvaluateRestOfPageAfterEndTag()
128     {
129         
130         //
131
// TODO: code that determines whether the rest of the page
132
// should be evaluated after the tag is processed
133
// should be placed here.
134
// Called from the doEndTag() method.
135
//
136
return true;
137         
138     }
139     
140     
141     ////////////////////////////////////////////////////////////////
142
/// ///
143
/// Tag Handler interface methods. ///
144
/// ///
145
/// Do not modify these methods; instead, modify the ///
146
/// methods that they call. ///
147
/// ///
148
////////////////////////////////////////////////////////////////
149

150     
151     /**
152      * Dummy javadoc comment to get things started.
153      */

154     public int doStartTag() throws JspException JavaDoc
155     {
156         if(this.getParent() instanceof albel.tags.table.ColumnTag)
157         {
158             HttpServletRequest JavaDoc request=(HttpServletRequest JavaDoc)pageContext.getRequest();
159             HttpSessionAttributesMap attrs=new HttpSessionAttributesMap(request.getSession());
160             TableTag tableTag=(TableTag)this.getParent().getParent().getParent();
161             ColumnTag colTag=(ColumnTag)this.getParent();
162             Table table=Manager.getTable(attrs, tableTag.getId());
163             Column col=table.getColumn(colTag.getProperty());
164             if(col.getHeader()!=null)
165             {
166                 ColumnHeader ch=new ColumnHeader();
167                 ch.setTitle(getTitle());
168                 ch.setAlign(getAlign());
169                 ch.setColumn(col);
170                 ch.setCssClass(getCssClass());
171                 col.setHeader(ch);
172             }
173         }
174         return this.EVAL_BODY_INCLUDE;
175     }
176     
177     /**
178      * Dummy javadoc comment to get things started.
179      */

180     public int doEndTag() throws JspException JavaDoc
181     {
182         // Dummy body to get things going.
183
return EVAL_PAGE;
184     }
185     
186     /**
187      * Getter for property title.
188      * @return Value of property title.
189      */

190     public String JavaDoc getTitle()
191     {
192         return this.title;
193     }
194     
195     /**
196      * Setter for property title.
197      * @param title New value of property title.
198      */

199     public void setTitle(String JavaDoc title)
200     {
201         this.title = title;
202     }
203     
204     /**
205      * Getter for property align.
206      * @return Value of property align.
207      */

208     public String JavaDoc getAlign()
209     {
210         return this.align;
211     }
212     
213     /**
214      * Setter for property align.
215      * @param align New value of property align.
216      */

217     public void setAlign(String JavaDoc align)
218     {
219         this.align = align;
220     }
221     
222     /**
223      * Getter for property cssClass.
224      * @return Value of property cssClass.
225      */

226     public String JavaDoc getCssClass()
227     {
228         return this.cssClass;
229     }
230     
231     /**
232      * Setter for property cssClass.
233      * @param cssClass New value of property cssClass.
234      */

235     public void setCssClass(String JavaDoc cssClass)
236     {
237         this.cssClass = cssClass;
238     }
239     
240 }
241
Popular Tags