KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * Jan 18, 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 enable.
27  *
28  * @author jonni
29  * @author hgani
30  * @version $Id$
31  */

32 public class EnableTag 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 = "enableElements";
46
47
48   ////////////////////////////
49
////////// Fields //////////
50
////////////////////////////
51

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

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

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

67   /**
68    * Default constructor.
69    */

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

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

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

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

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

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