KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: ELImportAttributeTag.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.ImportAttributeTag;
22 import javax.servlet.jsp.JspException JavaDoc;
23 import org.apache.strutsel.taglib.utils.EvalHelper;
24
25 /**
26   * Import attribute from component to requested scope.
27   * Attribute name and scope are optional. If not specified, all component
28   * attributes are imported in page scope.
29  *<p>
30  * This class is a subclass of the class
31  * <code>org.apache.struts.taglib.tiles.ImportAttributeTag</code> which provides most of
32  * the described functionality. This subclass allows all attribute values to
33  * be specified as expressions utilizing the JavaServer Pages Standard Library
34  * expression language.
35  *
36  * @version $Rev: 54933 $
37  */

38 public class ELImportAttributeTag extends ImportAttributeTag {
39
40     /**
41      * Instance variable mapped to "scope" tag attribute.
42      * (Mapping set in associated BeanInfo class.)
43      */

44     private String JavaDoc scopeExpr;
45     /**
46      * Instance variable mapped to "name" tag attribute.
47      * (Mapping set in associated BeanInfo class.)
48      */

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

54     private String JavaDoc ignoreExpr;
55
56     /**
57      * Getter method for "scope" tag attribute.
58      * (Mapping set in associated BeanInfo class.)
59      */

60     public String JavaDoc getScopeExpr() { return (scopeExpr); }
61     /**
62      * Getter method for "name" tag attribute.
63      * (Mapping set in associated BeanInfo class.)
64      */

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

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

76     public void setScopeExpr(String JavaDoc scopeExpr) { this.scopeExpr = scopeExpr; }
77     /**
78      * Setter method for "name" tag attribute.
79      * (Mapping set in associated BeanInfo class.)
80      */

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

86     public void setIgnoreExpr(String JavaDoc ignoreExpr) { this.ignoreExpr = ignoreExpr; }
87
88     /**
89      * Resets attribute values for tag reuse.
90      */

91     public void release()
92     {
93         super.release();
94         setScopeExpr(null);
95         setNameExpr(null);
96         setIgnoreExpr(null);
97     }
98     
99     /**
100      * Process the start tag.
101      *
102      * @exception JspException if a JSP exception has occurred
103      */

104     public int doStartTag() throws JspException JavaDoc {
105         evaluateExpressions();
106         return (super.doStartTag());
107     }
108     
109     /**
110      * Processes all attribute values which use the JSTL expression evaluation
111      * engine to determine their values.
112      *
113      * @exception JspException if a JSP exception has occurred
114      */

115     private void evaluateExpressions() throws JspException JavaDoc {
116         String JavaDoc string = null;
117         Boolean JavaDoc bool = null;
118
119         if ((string = EvalHelper.evalString("scope", getScopeExpr(),
120                                             this, pageContext)) != null)
121             setScope(string);
122         if ((string = EvalHelper.evalString("name", getNameExpr(),
123                                             this, pageContext)) != null)
124             setName(string);
125         if ((bool = EvalHelper.evalBoolean("ignore", getIgnoreExpr(),
126                                            this, pageContext)) != null)
127             setIgnore(bool.booleanValue());
128     }
129 }
130
Popular Tags