KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: ELGetTag.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.GetTag;
22 import javax.servlet.jsp.JspException JavaDoc;
23 import org.apache.strutsel.taglib.utils.EvalHelper;
24
25 /**
26  * This is the tag handler for <tiles-el:get>, which gets
27  * content from the request scope and either includes the content or prints
28  * it, depending upon the value of the content's <code>direct</code> attribute.
29  *<p>
30  * This tag is intended to be compatible with the same tag from Templates
31  * (David Geary). Implementation extends InsertTag for facility (no so well).
32  * The only difference is the default value of attribute 'ignore', which is
33  * <code>true</code> for this tag (default behavior of David Geary's
34  * templates).
35  *<p>
36  * This class is a subclass of the class
37  * <code>org.apache.struts.taglib.tiles.GetTag</code> which provides most of
38  * the described functionality. This subclass allows all attribute values to
39  * be specified as expressions utilizing the JavaServer Pages Standard Library
40  * expression language.
41  *
42  * @version $Rev: 54933 $
43  */

44 public class ELGetTag extends GetTag {
45
46     /**
47      * Instance variable mapped to "name" tag attribute.
48      * (Mapping set in associated BeanInfo class.)
49      */

50     private String JavaDoc nameExpr;
51     /**
52      * Instance variable mapped to "ignore" tag attribute.
53      * (Mapping set in associated BeanInfo class.)
54      */

55     private String JavaDoc ignoreExpr;
56     /**
57      * Instance variable mapped to "flush" tag attribute.
58      * (Mapping set in associated BeanInfo class.)
59      */

60     private String JavaDoc flushExpr;
61     /**
62      * Instance variable mapped to "role" tag attribute.
63      * (Mapping set in associated BeanInfo class.)
64      */

65     private String JavaDoc roleExpr;
66
67     /**
68      * Getter method for "name" tag attribute.
69      * (Mapping set in associated BeanInfo class.)
70      */

71     public String JavaDoc getNameExpr() { return (nameExpr); }
72     /**
73      * Getter method for "ignore" tag attribute.
74      * (Mapping set in associated BeanInfo class.)
75      */

76     public String JavaDoc getIgnoreExpr() { return (ignoreExpr); }
77     /**
78      * Getter method for "flush" tag attribute.
79      * (Mapping set in associated BeanInfo class.)
80      */

81     public String JavaDoc getFlushExpr() { return (flushExpr); }
82     /**
83      * Getter method for "role" tag attribute.
84      * (Mapping set in associated BeanInfo class.)
85      */

86     public String JavaDoc getRoleExpr() { return (roleExpr); }
87
88     /**
89      * Setter method for "name" tag attribute.
90      * (Mapping set in associated BeanInfo class.)
91      */

92     public void setNameExpr(String JavaDoc nameExpr) { this.nameExpr = nameExpr; }
93     /**
94      * Setter method for "ignore" tag attribute.
95      * (Mapping set in associated BeanInfo class.)
96      */

97     public void setIgnoreExpr(String JavaDoc ignoreExpr) { this.ignoreExpr = ignoreExpr; }
98     /**
99      * Setter method for "flush" tag attribute.
100      * (Mapping set in associated BeanInfo class.)
101      */

102     public void setFlushExpr(String JavaDoc flushExpr) { this.flushExpr = flushExpr; }
103     /**
104      * Setter method for "role" tag attribute.
105      * (Mapping set in associated BeanInfo class.)
106      */

107     public void setRoleExpr(String JavaDoc roleExpr) { this.roleExpr = roleExpr; }
108
109     /**
110      * Resets attribute values for tag reuse.
111      */

112     public void release()
113     {
114         super.release();
115         setNameExpr(null);
116         setIgnoreExpr(null);
117         setFlushExpr(null);
118         setRoleExpr(null);
119     }
120     
121     /**
122      * Process the start tag.
123      *
124      * @exception JspException if a JSP exception has occurred
125      */

126     public int doStartTag() throws JspException JavaDoc {
127         evaluateExpressions();
128         return (super.doStartTag());
129     }
130     
131     /**
132      * Processes all attribute values which use the JSTL expression evaluation
133      * engine to determine their values.
134      *
135      * @exception JspException if a JSP exception has occurred
136      */

137     private void evaluateExpressions() throws JspException JavaDoc {
138         String JavaDoc string = null;
139         Boolean JavaDoc bool = null;
140
141         if ((string = EvalHelper.evalString("name", getNameExpr(),
142                                             this, pageContext)) != null)
143             setName(string);
144         if ((bool = EvalHelper.evalBoolean("ignore", getIgnoreExpr(),
145                                            this, pageContext)) != null)
146             setIgnore(bool.booleanValue());
147         if ((string = EvalHelper.evalString("flush", getFlushExpr(),
148                                             this, pageContext)) != null)
149             setFlush(string);
150         if ((string = EvalHelper.evalString("role", getRoleExpr(),
151                                             this, pageContext)) != null)
152             setRole(string);
153     }
154 }
155
Popular Tags