KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * Nov 15, 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 /**
27  * Injects the functionality for the source box of an option transfer suite.
28  *
29  * @author hgani
30  * @version $Id$
31  */

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

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

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

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

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

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

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

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

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

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

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