KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > uitags > tag > panel > StickTag


1 /**
2  * May 1, 2006
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.panel;
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 a stick capability to a widget of a panel.
28  *
29  * @author hgani
30  * @version $Id$
31  */

32 public class StickTag 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    * Instructs web container to skip the tag's body.
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     return SKIP_BODY;
95   }
96
97   /**
98    * Passes code generated by the child tag to its parent.
99    *
100    * @see javax.servlet.jsp.tagext.Tag#doEndTag()
101    * @return <code>EVAL_PAGE</code>
102    * @throws JspException to communicate error
103    */

104   public int doEndTag() throws JspException JavaDoc {
105     RuntimeValidator.assertAttributeExclusive(
106         "injectTo", this.injectTo, "injectToName", this.injectToName);
107     RuntimeValidator.assertEitherSpecified(
108         "injectTo", this.injectTo, "injectToName", this.injectToName);
109
110     PanelTag parent = (PanelTag) findParent(PanelTag.class);
111
112     Template tpl = Template.forName(Template.PANEL_STICK);
113     tpl.map("stickerId", this.injectTo);
114     tpl.map("stickerName", this.injectToName);
115     parent.addChildJsCode(tpl.evalToString());
116
117     return EVAL_PAGE;
118   }
119 }
120
Popular Tags