KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: ELGetAttributeTag.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.GetAttributeTag;
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.GetAttributeTag</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 ELGetAttributeTag extends GetAttributeTag {
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 "role" tag attribute.
58      * (Mapping set in associated BeanInfo class.)
59      */

60     private String JavaDoc roleExpr;
61
62     /**
63      * Getter method for "name" tag attribute.
64      * (Mapping set in associated BeanInfo class.)
65      */

66     public String JavaDoc getNameExpr() { return (nameExpr); }
67     /**
68      * Getter method for "ignore" tag attribute.
69      * (Mapping set in associated BeanInfo class.)
70      */

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

76     public String JavaDoc getRoleExpr() { return (roleExpr); }
77
78     /**
79      * Setter method for "name" tag attribute.
80      * (Mapping set in associated BeanInfo class.)
81      */

82     public void setNameExpr(String JavaDoc nameExpr) { this.nameExpr = nameExpr; }
83     /**
84      * Setter method for "ignore" tag attribute.
85      * (Mapping set in associated BeanInfo class.)
86      */

87     public void setIgnoreExpr(String JavaDoc ignoreExpr) { this.ignoreExpr = ignoreExpr; }
88     /**
89      * Setter method for "role" tag attribute.
90      * (Mapping set in associated BeanInfo class.)
91      */

92     public void setRoleExpr(String JavaDoc roleExpr) { this.roleExpr = roleExpr; }
93
94     /**
95      * Resets attribute values for tag reuse.
96      */

97     public void release()
98     {
99         super.release();
100         setNameExpr(null);
101         setIgnoreExpr(null);
102         setRoleExpr(null);
103     }
104     
105     /**
106      * Process the start tag.
107      *
108      * @exception JspException if a JSP exception has occurred
109      */

110     public int doStartTag() throws JspException JavaDoc {
111         evaluateExpressions();
112         return (super.doStartTag());
113     }
114     
115     /**
116      * Processes all attribute values which use the JSTL expression evaluation
117      * engine to determine their values.
118      *
119      * @exception JspException if a JSP exception has occurred
120      */

121     private void evaluateExpressions() throws JspException JavaDoc {
122         String JavaDoc string = null;
123         Boolean JavaDoc bool = null;
124
125         if ((string = EvalHelper.evalString("name", getNameExpr(),
126                                             this, pageContext)) != null)
127             setName(string);
128         if ((bool = EvalHelper.evalBoolean("ignore", getIgnoreExpr(),
129                                            this, pageContext)) != null)
130             setIgnore(bool.booleanValue());
131         if ((string = EvalHelper.evalString("role", getRoleExpr(),
132                                             this, pageContext)) != null)
133             setRole(string);
134     }
135 }
136
Popular Tags