KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > uitags > tag > formGuide > ObserveForNullTag


1 /**
2  * Jan 16, 2005
3  *
4  * Copyright 2004 - 2005 uitags
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package net.sf.uitags.tag.formGuide;
19
20 import javax.servlet.jsp.JspException JavaDoc;
21
22 import net.sf.uitags.tag.AbstractUiTag;
23 import net.sf.uitags.tagutil.validation.RuntimeValidator;
24
25 /**
26  * Notifies {@link net.sf.uitags.tag.formGuide.FormGuideTag} of widgets to observe.
27  *
28  * @author jonni
29  * @version $Id$
30  */

31 public class ObserveForNullTag extends AbstractUiTag {
32   ///////////////////////////////
33
////////// Constants //////////
34
///////////////////////////////
35

36   /**
37    * Serial Version UID.
38    */

39   private static final long serialVersionUID = 100L;
40
41
42
43   ////////////////////////////
44
////////// Fields //////////
45
////////////////////////////
46

47   /**
48    * The "elementId" tag attribute
49    */

50   protected String JavaDoc elementId;
51   /**
52    * The "elementName" tag attribute
53    */

54   protected String JavaDoc elementName;
55
56
57
58   //////////////////////////////////
59
////////// Constructors //////////
60
//////////////////////////////////
61

62   /**
63    * Default constructor.
64    */

65   public ObserveForNullTag() {
66     super();
67   }
68
69
70
71   ///////////////////////////////////////////
72
////////// Tag attribute setters //////////
73
///////////////////////////////////////////
74

75   /**
76    * Tag attribute setter.
77    *
78    * @param val value of the tag attribute
79    */

80   public void setElementId(String JavaDoc val) {
81     this.elementId = val;
82   }
83
84   /**
85    * Tag attribute setter.
86    *
87    * @param val value of the tag attribute
88    */

89   public void setElementName(String JavaDoc val) {
90     this.elementName = val;
91   }
92
93
94
95   ///////////////////////////////
96
////////// Tag logic //////////
97
///////////////////////////////
98

99   /**
100    * Performs runtime validation and delegates to the overridable method
101    * {@link #doEndTagWithoutRuntimeValidation()}.
102    *
103    * @return <code>EVAL_PAGE</code>
104    * @throws JspException to communicate error
105    */

106   public final int doEndTag() throws JspException JavaDoc {
107     RuntimeValidator.assertAttributeExclusive(
108         "elementId", this.elementId, "elementName", this.elementName);
109     RuntimeValidator.assertEitherSpecified(
110         "elementId", this.elementId, "elementName", this.elementName);
111
112     doEndTagWithoutRuntimeValidation();
113
114     return EVAL_PAGE;
115   }
116
117   /**
118    * Performs the actual logic of {@link #doEndTag}. This implementation
119    * communicates with the parent tag ({@link FormGuideTag}).
120    *
121    * @throws JspException to communicate error
122    */

123   protected void doEndTagWithoutRuntimeValidation() {
124     FormGuideTag formGuideTag = (FormGuideTag) findParent(FormGuideTag.class);
125     if (this.elementId != null) {
126       formGuideTag.addObservedElementId(this.elementId, null);
127     }
128     else if (this.elementName != null) {
129       formGuideTag.addObservedElementName(this.elementName, null);
130     }
131   }
132 }
133
Popular Tags