KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > uitags > tag > calendar > CalendarTag


1 package net.sf.uitags.tag.calendar;
2
3 import java.util.ArrayList JavaDoc;
4 import java.util.List JavaDoc;
5
6 import javax.servlet.jsp.JspException JavaDoc;
7
8 import net.sf.uitags.tag.AbstractUiTag;
9 import net.sf.uitags.util.Template;
10
11 public class CalendarTag extends AbstractUiTag {
12   ///////////////////////////////
13
////////// Constants //////////
14
///////////////////////////////
15

16   /**
17    * Serial Version UID.
18    */

19   private static final long serialVersionUID = 100L;
20
21
22   ////////////////////////////
23
////////// Fields //////////
24
////////////////////////////
25

26   private CalendarGridTag calendarGrid;
27
28   /**
29    * List of code Strings generated by child tags, which is to be included
30    * somewhere in the parent's generated code.
31    */

32   private List JavaDoc childJsCodeList;
33
34
35   ///////////////////////////////
36
////////// Tag logic //////////
37
///////////////////////////////
38

39   public int doStartTag() throws JspException JavaDoc {
40     super.doStartTag();
41
42     this.childJsCodeList = new ArrayList JavaDoc();
43
44     makeVisibleToChildren();
45     return EVAL_BODY_INCLUDE;
46   }
47
48   public int doEndTag() throws JspException JavaDoc {
49     super.doEndTag();
50
51     printJsCode();
52
53     makeInvisibleFromChildren();
54     return EVAL_PAGE;
55   }
56
57   private void printJsCode() throws JspException JavaDoc {
58     Template tpl = Template.forName(Template.CALENDAR);
59
60     tpl.map("gridId", this.calendarGrid.getId());
61     tpl.map("gridClass", this.calendarGrid.getCssClass());
62     tpl.map("dayLabels", this.calendarGrid.getDayLabels());
63     tpl.map("classResolver", this.calendarGrid.getClassResolver());
64     tpl.map("actionResolver", this.calendarGrid.getActionResolver());
65     tpl.map("otherAttributes", this.calendarGrid.getCustomHtmlAttributes());
66     tpl.map("jsCodeList", this.childJsCodeList);
67
68     println(tpl.evalToString());
69   }
70
71
72   /////////////////////////////////////////////////////
73
////////// To be used by nested child tags //////////
74
/////////////////////////////////////////////////////
75

76   void setCalendarGrid(CalendarGridTag calendarGrid) {
77     this.calendarGrid = calendarGrid;
78   }
79
80   void addChildJsCode(String JavaDoc code) {
81     this.childJsCodeList.add(code);
82   }
83 }
84
Popular Tags