KickJava   Java API By Example, From Geeks To Geeks.

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


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 UpdateDateTag 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_EVENT =
26       "calendar.updateDate.on";
27
28   private static final String JavaDoc PROP_DATE_OBTAINER =
29       "calendar.updateDate.dateObtainer";
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 'on' tag attribute.
46    */

47   private String JavaDoc eventName;
48   /**
49    * The 'dateObtainer' tag attribute.
50    */

51   private String JavaDoc dateObtainer;
52
53
54   ///////////////////////////////////////////
55
////////// Tag attribute setters //////////
56
///////////////////////////////////////////
57

58   public void setInjectTo(String JavaDoc val) {
59     this.injectTo = val;
60   }
61
62   public void setInjectToName(String JavaDoc val) {
63     this.injectToName = val;
64   }
65
66   public void setOn(String JavaDoc val) {
67     this.eventName = val;
68   }
69
70   public void setDateObtainer(String JavaDoc val) {
71     this.dateObtainer = val;
72   }
73
74
75   ///////////////////////////////
76
////////// Tag logic //////////
77
///////////////////////////////
78

79   public int doStartTag() throws JspException JavaDoc {
80     return SKIP_BODY;
81   }
82
83   public int doEndTag() throws JspException JavaDoc {
84     RuntimeValidator.assertAttributeExclusive(
85         "injectTo", this.injectTo, "injectToName", this.injectToName);
86     RuntimeValidator.assertEitherSpecified(
87         "injectTo", this.injectTo, "injectToName", this.injectToName);
88
89     TaglibProperties props = TaglibProperties.getInstance();
90     props.setRuntimeProperty(PROP_EVENT, this.eventName);
91     props.setRuntimeProperty(PROP_DATE_OBTAINER, this.dateObtainer);
92
93     Template tpl = Template.forName(Template.CALENDAR_UPDATE_DATE);
94     tpl.map("triggerId", this.injectTo);
95     tpl.map("triggerName", this.injectToName);
96     tpl.map("triggerEvent", props.get(PROP_EVENT));
97     tpl.map("dateObtainer", props.get(PROP_DATE_OBTAINER));
98
99     CalendarTag parent = (CalendarTag) findParent(CalendarTag.class);
100     parent.addChildJsCode(tpl.evalToString());
101
102     return EVAL_PAGE;
103   }
104 }
105
Popular Tags