KickJava   Java API By Example, From Geeks To Geeks.

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


1 package net.sf.uitags.tag.calendar;
2
3 import javax.servlet.jsp.JspException JavaDoc;
4
5 import net.sf.uitags.tag.AbstractUiTag;
6 import net.sf.uitags.tagutil.TaglibProperties;
7 import net.sf.uitags.tagutil.i18n.MessageFinder;
8 import net.sf.uitags.tagutil.i18n.MessageFinderFactory;
9 import net.sf.uitags.tagutil.validation.RuntimeValidator;
10 import net.sf.uitags.util.ArrayUtils;
11 import net.sf.uitags.util.Template;
12
13 public class ListMonthsTag extends AbstractUiTag {
14   ///////////////////////////////
15
////////// Constants //////////
16
///////////////////////////////
17

18   /**
19    * Serial Version UID.
20    */

21   private static final long serialVersionUID = 100L;
22
23
24   ///////////////////////////////////////////////
25
////////// Property keys (constants) //////////
26
///////////////////////////////////////////////
27

28   private static final String JavaDoc PROP_MONTH_LABELS =
29       "calendar.listMonths.monthLabels";
30
31
32   ////////////////////////////
33
////////// Fields //////////
34
////////////////////////////
35

36   /**
37    * The 'injectTo' tag attribute.
38    */

39   private String JavaDoc injectTo;
40   /**
41    * The 'injectToName' tag attribute.
42    */

43   private String JavaDoc injectToName;
44   /**
45    * The 'monthLabels' tag attribute.
46    */

47   private String JavaDoc[] monthLabels;
48
49
50   ///////////////////////////////////////////
51
////////// Tag attribute setters //////////
52
///////////////////////////////////////////
53

54   public void setInjectTo(String JavaDoc val) {
55     this.injectTo = val;
56   }
57
58   public void setInjectToName(String JavaDoc val) {
59     this.injectToName = val;
60   }
61
62   public void setMonthLabels(String JavaDoc[] val) {
63     this.monthLabels = val;
64   }
65
66
67   ///////////////////////////////
68
////////// Tag logic //////////
69
///////////////////////////////
70

71   public int doStartTag() throws JspException JavaDoc {
72     return SKIP_BODY;
73   }
74
75   public int doEndTag() throws JspException JavaDoc {
76     RuntimeValidator.assertAttributeExclusive(
77         "injectTo", this.injectTo, "injectToName", this.injectToName);
78     RuntimeValidator.assertEitherSpecified(
79         "injectTo", this.injectTo, "injectToName", this.injectToName);
80
81     if (this.monthLabels == null) {
82       TaglibProperties props = TaglibProperties.getInstance();
83       MessageFinder messageFinder =
84           MessageFinderFactory.getInstance(this.pageContext);
85       this.monthLabels =
86           ArrayUtils.toArray(messageFinder.get(props.get(PROP_MONTH_LABELS)));
87     }
88
89     Template tpl = Template.forName(Template.CALENDAR_LIST_MONTHS);
90     tpl.map("listerId", this.injectTo);
91     tpl.map("listerName", this.injectToName);
92     tpl.map("monthLabels", this.monthLabels);
93
94     CalendarTag parent = (CalendarTag) findParent(CalendarTag.class);
95     parent.addChildJsCode(tpl.evalToString());
96
97     return EVAL_PAGE;
98   }
99 }
100
Popular Tags