KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > uitags > tag > optionTransfer > TargetTag


1 /**
2  * Nov 19, 2004
3  *
4  * Copyright 2004 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.optionTransfer;
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  * Injects the functionality for the target box of an option transfer suite.
27  *
28  * @author hgani
29  * @version $Id$
30  */

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

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

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

47   /**
48    * The 'injectTo' tag attribute.
49    */

50   private String JavaDoc injectTo;
51
52   /**
53    * The 'injectToName' tag attribute.
54    */

55   private String JavaDoc injectToName;
56
57
58   ///////////////////////////////////////////
59
////////// Tag attribute setters //////////
60
///////////////////////////////////////////
61

62   /**
63    * Tag attribute setter.
64    *
65    * @param val value of the tag attribute
66    */

67   public void setInjectTo(String JavaDoc val) {
68     this.injectTo = val;
69   }
70
71   /**
72    * Tag attribute setter.
73    *
74    * @param val value of the tag attribute
75    */

76   public void setInjectToName(String JavaDoc val) {
77     this.injectToName = val;
78   }
79
80
81   ///////////////////////////////
82
////////// Tag logic //////////
83
///////////////////////////////
84

85   /**
86    * Registers to the parent and prints the necessary Javascript code.
87    *
88    * @see javax.servlet.jsp.tagext.Tag#doStartTag()
89    * @return <code>SKIP_BODY</code>
90    * @throws JspException to communicate error
91    */

92   public int doStartTag() throws JspException JavaDoc {
93     RuntimeValidator.assertAttributeExclusive(
94         "injectTo", this.injectTo, "injectToName", this.injectToName);
95     RuntimeValidator.assertEitherSpecified(
96         "injectTo", this.injectTo, "injectToName", this.injectToName);
97
98     OptionTransferTag parent = (OptionTransferTag) findParent(
99         OptionTransferTag.class);
100     parent.registerTargetLister(this.injectTo, this.injectToName);
101
102     return SKIP_BODY;
103   }
104 }
105
Popular Tags