KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: ELInitDefinitionsTag.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.InitDefinitionsTag;
22 import javax.servlet.jsp.JspException JavaDoc;
23 import org.apache.strutsel.taglib.utils.EvalHelper;
24
25 /**
26  * Init definitions factory.
27  *<p>
28  * This class is a subclass of the class
29  * <code>org.apache.struts.taglib.tiles.InitDefinitionsTag</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 ELInitDefinitionsTag extends InitDefinitionsTag {
37
38     /**
39      * Instance variable mapped to "file" tag attribute.
40      * (Mapping set in associated BeanInfo class.)
41      */

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

47     private String JavaDoc classnameExpr;
48
49     /**
50      * Getter method for "file" tag attribute.
51      * (Mapping set in associated BeanInfo class.)
52      */

53     public String JavaDoc getFileExpr() { return (fileExpr); }
54     /**
55      * Getter method for "classname" tag attribute.
56      * (Mapping set in associated BeanInfo class.)
57      */

58     public String JavaDoc getClassnameExpr() { return (classnameExpr); }
59
60     /**
61      * Setter method for "file" tag attribute.
62      * (Mapping set in associated BeanInfo class.)
63      */

64     public void setFileExpr(String JavaDoc fileExpr) { this.fileExpr = fileExpr; }
65     /**
66      * Setter method for "classname" tag attribute.
67      * (Mapping set in associated BeanInfo class.)
68      */

69     public void setClassnameExpr(String JavaDoc classnameExpr) { this.classnameExpr = classnameExpr; }
70
71     /**
72      * Resets attribute values for tag reuse.
73      */

74     public void release()
75     {
76         super.release();
77         setFileExpr(null);
78         setClassnameExpr(null);
79     }
80     
81     /**
82      * Process the start tag.
83      *
84      * @exception JspException if a JSP exception has occurred
85      */

86     public int doStartTag() throws JspException JavaDoc {
87         evaluateExpressions();
88         return (super.doStartTag());
89     }
90     
91     /**
92      * Processes all attribute values which use the JSTL expression evaluation
93      * engine to determine their values.
94      *
95      * @exception JspException if a JSP exception has occurred
96      */

97     private void evaluateExpressions() throws JspException JavaDoc {
98         String JavaDoc string = null;
99
100         if ((string = EvalHelper.evalString("file", getFileExpr(),
101                                             this, pageContext)) != null)
102             setFile(string);
103         if ((string = EvalHelper.evalString("classname", getClassnameExpr(),
104                                             this, pageContext)) != null)
105             setClassname(string);
106     }
107 }
108
Popular Tags