KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > strutsel > taglib > tiles > ELUseAttributeTag


1 /*
2  * $Id: ELUseAttributeTag.java 54933 2004-10-16 17:04:52Z germuska $
3  *
4  * Copyright 1999-2004 The Apache Software Foundation.
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
19 package org.apache.strutsel.taglib.tiles;
20
21 import org.apache.struts.taglib.tiles.UseAttributeTag;
22 import javax.servlet.jsp.JspException JavaDoc;
23 import org.apache.strutsel.taglib.utils.EvalHelper;
24
25 /**
26  * Custom tag exposing a component attribute to page.
27  *<p>
28  * This class is a subclass of the class
29  * <code>org.apache.struts.taglib.tiles.UseAttributeTag</code> which provides most of
30  * the described functionality. This subclass allows all attribute values to
31  * be specified as expressions utilizing the JavaServer Pages Standard Library
32  * expression language.
33  *
34  * @version $Rev: 54933 $
35  */

36 public class ELUseAttributeTag extends UseAttributeTag {
37
38     /**
39      * Instance variable mapped to "id" tag attribute.
40      * (Mapping set in associated BeanInfo class.)
41      */

42     private String JavaDoc idExpr;
43     /**
44      * Instance variable mapped to "classname" tag attribute.
45      * (Mapping set in associated BeanInfo class.)
46      */

47     private String JavaDoc classnameExpr;
48     /**
49      * Instance variable mapped to "scope" tag attribute.
50      * (Mapping set in associated BeanInfo class.)
51      */

52     private String JavaDoc scopeExpr;
53     /**
54      * Instance variable mapped to "name" tag attribute.
55      * (Mapping set in associated BeanInfo class.)
56      */

57     private String JavaDoc nameExpr;
58     /**
59      * Instance variable mapped to "ignore" tag attribute.
60      * (Mapping set in associated BeanInfo class.)
61      */

62     private String JavaDoc ignoreExpr;
63
64     /**
65      * Getter method for "id" tag attribute.
66      * (Mapping set in associated BeanInfo class.)
67      */

68     public String JavaDoc getIdExpr() { return (idExpr); }
69     /**
70      * Getter method for "classname" tag attribute.
71      * (Mapping set in associated BeanInfo class.)
72      */

73     public String JavaDoc getClassnameExpr() { return (classnameExpr); }
74     /**
75      * Getter method for "scope" tag attribute.
76      * (Mapping set in associated BeanInfo class.)
77      */

78     public String JavaDoc getScopeExpr() { return (scopeExpr); }
79     /**
80      * Getter method for "name" tag attribute.
81      * (Mapping set in associated BeanInfo class.)
82      */

83     public String JavaDoc getNameExpr() { return (nameExpr); }
84     /**
85      * Getter method for "ignore" tag attribute.
86      * (Mapping set in associated BeanInfo class.)
87      */

88     public String JavaDoc getIgnoreExpr() { return (ignoreExpr); }
89
90     /**
91      * Setter method for "id" tag attribute.
92      * (Mapping set in associated BeanInfo class.)
93      */

94     public void setIdExpr(String JavaDoc idExpr) { this.idExpr = idExpr; }
95     /**
96      * Setter method for "classname" tag attribute.
97      * (Mapping set in associated BeanInfo class.)
98      */

99     public void setClassnameExpr(String JavaDoc classnameExpr) { this.classnameExpr = classnameExpr; }
100     /**
101      * Setter method for "scope" tag attribute.
102      * (Mapping set in associated BeanInfo class.)
103      */

104     public void setScopeExpr(String JavaDoc scopeExpr) { this.scopeExpr = scopeExpr; }
105     /**
106      * Setter method for "name" tag attribute.
107      * (Mapping set in associated BeanInfo class.)
108      */

109     public void setNameExpr(String JavaDoc nameExpr) { this.nameExpr = nameExpr; }
110     /**
111      * Setter method for "ignore" tag attribute.
112      * (Mapping set in associated BeanInfo class.)
113      */

114     public void setIgnoreExpr(String JavaDoc ignoreExpr) { this.ignoreExpr = ignoreExpr; }
115
116     /**
117      * Resets attribute values for tag reuse.
118      */

119     public void release()
120     {
121         super.release();
122         setIdExpr(null);
123         setClassnameExpr(null);
124         setScopeExpr(null);
125         setNameExpr(null);
126         setIgnoreExpr(null);
127     }
128     
129     /**
130      * Process the start tag.
131      *
132      * @exception JspException if a JSP exception has occurred
133      */

134     public int doStartTag() throws JspException JavaDoc {
135         evaluateExpressions();
136         return (super.doStartTag());
137     }
138     
139     /**
140      * Processes all attribute values which use the JSTL expression evaluation
141      * engine to determine their values.
142      *
143      * @exception JspException if a JSP exception has occurred
144      */

145     private void evaluateExpressions() throws JspException JavaDoc {
146         String JavaDoc string = null;
147         Boolean JavaDoc bool = null;
148
149         if ((string = EvalHelper.evalString("id", getIdExpr(),
150                                             this, pageContext)) != null)
151             setId(string);
152         if ((string = EvalHelper.evalString("classname", getClassnameExpr(),
153                                             this, pageContext)) != null)
154             setClassname(string);
155         if ((string = EvalHelper.evalString("scope", getScopeExpr(),
156                                             this, pageContext)) != null)
157             setScope(string);
158         if ((string = EvalHelper.evalString("name", getNameExpr(),
159                                             this, pageContext)) != null)
160             setName(string);
161         if ((bool = EvalHelper.evalBoolean("ignore", getIgnoreExpr(),
162                                            this, pageContext)) != null)
163             setIgnore(bool.booleanValue());
164     }
165 }
166
Popular Tags