KickJava   Java API By Example, From Geeks To Geeks.

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


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 disable.
27  *
28  * @author jonni
29  * @author hgani
30  * @version $Id$
31  */

32 public class DisableTag extends AbstractUiTag {
33   ///////////////////////////////
34
////////// Constants //////////
35
///////////////////////////////
36

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

40   private static final long serialVersionUID = 100L;
41
42   /**
43    * Javascript callback for elements.
44    */

45   static final String JavaDoc CALLBACK_METHOD = "disableElements";
46
47
48   ////////////////////////////
49
////////// Fields //////////
50
////////////////////////////
51

52   /**
53    * The "elementId" tag attribute
54    */

55   private String JavaDoc elementId;
56
57   /**
58    * The "widgetName" tag attribute
59    */

60   private String JavaDoc elementName;
61
62
63
64   //////////////////////////////////
65
////////// Constructors //////////
66
//////////////////////////////////
67

68   /**
69    * Default constructor.
70    */

71   public DisableTag() {
72     super();
73   }
74
75
76
77   ///////////////////////////////////////////
78
////////// Tag attribute setters //////////
79
///////////////////////////////////////////
80

81   /**
82    * Tag attribute setter.
83    *
84    * @param val value of the tag attribute
85    */

86   public void setElementId(String JavaDoc val) {
87     this.elementId = val;
88   }
89
90   /**
91    * Tag attribute setter.
92    *
93    * @param val value of the tag attribute
94    */

95   public void setElementName(String JavaDoc val) {
96     this.elementName = val;
97   }
98
99
100
101   ///////////////////////////////
102
////////// Tag logic //////////
103
///////////////////////////////
104

105   /**
106    * Communicates with the parent tag ({@link FormGuideTag}).
107    *
108    * @return <code>EVAL_PAGE</code>
109    * @throws JspException to communicate error
110    */

111   public int doEndTag() throws JspException JavaDoc {
112     RuntimeValidator.assertAttributeExclusive(
113         "elementId", this.elementId, "elementName", this.elementName);
114     RuntimeValidator.assertEitherSpecified(
115         "elementId", this.elementId, "elementName", this.elementName);
116
117     FormGuideTag formGuideTag = (FormGuideTag) findParent(FormGuideTag.class);
118     formGuideTag.addJavascriptCallback(CALLBACK_METHOD,
119         EnableTag.CALLBACK_METHOD, this.elementId, this.elementName);
120
121     return EVAL_PAGE;
122   }
123 }
124
Popular Tags