KickJava   Java API By Example, From Geeks To Geeks.

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


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.validation.RuntimeValidator;
8 import net.sf.uitags.util.Template;
9
10 public class ListYearsTag extends AbstractUiTag {
11   ///////////////////////////////
12
////////// Constants //////////
13
///////////////////////////////
14

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

18   private static final long serialVersionUID = 100L;
19
20
21   ///////////////////////////////////////////////
22
////////// Property keys (constants) //////////
23
///////////////////////////////////////////////
24

25   private static final String JavaDoc PROP_LISTING_STRATEGY =
26     "calendar.listYears.yearListObtainer";
27
28
29   ////////////////////////////
30
////////// Fields //////////
31
////////////////////////////
32

33   /**
34    * The 'injectTo' tag attribute.
35    */

36   private String JavaDoc injectTo;
37   /**
38    * The 'injectToName' tag attribute.
39    */

40   private String JavaDoc injectToName;
41   /**
42    * The 'yearListObtainer' tag attribute.
43    */

44   private String JavaDoc yearListObtainer;
45
46
47   ///////////////////////////////////////////
48
////////// Tag attribute setters //////////
49
///////////////////////////////////////////
50

51   public void setInjectTo(String JavaDoc val) {
52     this.injectTo = val;
53   }
54
55   public void setInjectToName(String JavaDoc val) {
56     this.injectToName = val;
57   }
58
59   public void setYearListObtainer(String JavaDoc val) {
60     this.yearListObtainer = val;
61   }
62
63
64   ///////////////////////////////
65
////////// Tag logic //////////
66
///////////////////////////////
67

68   public int doStartTag() throws JspException JavaDoc {
69     return SKIP_BODY;
70   }
71
72   public int doEndTag() throws JspException JavaDoc {
73     RuntimeValidator.assertAttributeExclusive(
74         "injectTo", this.injectTo, "injectToName", this.injectToName);
75     RuntimeValidator.assertEitherSpecified(
76         "injectTo", this.injectTo, "injectToName", this.injectToName);
77
78     TaglibProperties props = TaglibProperties.getInstance();
79     props.setRuntimeProperty(PROP_LISTING_STRATEGY, this.yearListObtainer);
80
81     Template tpl = Template.forName(Template.CALENDAR_LIST_YEARS);
82     tpl.map("listerId", this.injectTo);
83     tpl.map("listerName", this.injectToName);
84     tpl.map("yearListObtainer", props.get(PROP_LISTING_STRATEGY));
85
86     CalendarTag parent = (CalendarTag) findParent(CalendarTag.class);
87     parent.addChildJsCode(tpl.evalToString());
88
89     return EVAL_PAGE;
90   }
91 }
Popular Tags