KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * Nov 20, 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 import net.sf.uitags.util.Template;
25
26 /**
27  * Injects the functionality to transfer selected items in the source
28  * box to the target box of the option transfer suite.
29  *
30  * @author hgani
31  * @version $Id$
32  */

33 public class TransferTag extends AbstractUiTag {
34
35   ///////////////////////////////
36
////////// Constants //////////
37
///////////////////////////////
38

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

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

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

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

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

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

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

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

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

94   public int doStartTag() throws JspException JavaDoc {
95     RuntimeValidator.assertAttributeExclusive(
96         "injectTo", this.injectTo, "injectToName", this.injectToName);
97     RuntimeValidator.assertEitherSpecified(
98         "injectTo", this.injectTo, "injectToName", this.injectToName);
99
100     Template tpl = Template.forName(Template.OPTION_TRANSFER_TRANSFER);
101     tpl.map("triggerId", this.injectTo);
102     tpl.map("triggerName", this.injectToName);
103
104     OptionTransferTag parent = (OptionTransferTag) findParent(
105         OptionTransferTag.class);
106     parent.addChildJsCode(tpl.evalToString());
107
108     return SKIP_BODY;
109   }
110 }
111
Popular Tags