KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > strutsel > taglib > bean > ELStrutsTag


1 /*
2  * $Id: ELStrutsTag.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.bean;
20
21 import org.apache.struts.taglib.bean.StrutsTag;
22 import javax.servlet.jsp.JspException JavaDoc;
23 import org.apache.strutsel.taglib.utils.EvalHelper;
24
25 /**
26  * Define a scripting variable that exposes the requested Struts
27  * internal configuraton object.
28  *<p>
29  * This class is a subclass of the class
30  * <code>org.apache.struts.taglib.bean.StrutsTag</code> which provides most of
31  * the described functionality. This subclass allows all attribute values to
32  * be specified as expressions utilizing the JavaServer Pages Standard Library
33  * expression language.
34  *
35  * @version $Rev: 54933 $
36  */

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

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

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

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

58     private String JavaDoc mappingExpr;
59
60     /**
61      * Getter method for "id" tag attribute.
62      * (Mapping set in associated BeanInfo class.)
63      */

64     public String JavaDoc getIdExpr() { return (idExpr); }
65     /**
66      * Getter method for "formBean" tag attribute.
67      * (Mapping set in associated BeanInfo class.)
68      */

69     public String JavaDoc getFormBeanExpr() { return (formBeanExpr); }
70     /**
71      * Getter method for "forward" tag attribute.
72      * (Mapping set in associated BeanInfo class.)
73      */

74     public String JavaDoc getForwardExpr() { return (forwardExpr); }
75     /**
76      * Getter method for "mapping" tag attribute.
77      * (Mapping set in associated BeanInfo class.)
78      */

79     public String JavaDoc getMappingExpr() { return (mappingExpr); }
80
81     /**
82      * Setter method for "id" tag attribute.
83      * (Mapping set in associated BeanInfo class.)
84      */

85     public void setIdExpr(String JavaDoc idExpr) { this.idExpr = idExpr; }
86     /**
87      * Setter method for "formBean" tag attribute.
88      * (Mapping set in associated BeanInfo class.)
89      */

90     public void setFormBeanExpr(String JavaDoc formBeanExpr) { this.formBeanExpr = formBeanExpr; }
91     /**
92      * Setter method for "forward" tag attribute.
93      * (Mapping set in associated BeanInfo class.)
94      */

95     public void setForwardExpr(String JavaDoc forwardExpr) { this.forwardExpr = forwardExpr; }
96     /**
97      * Setter method for "mapping" tag attribute.
98      * (Mapping set in associated BeanInfo class.)
99      */

100     public void setMappingExpr(String JavaDoc mappingExpr) { this.mappingExpr = mappingExpr; }
101
102     /**
103      * Resets attribute values for tag reuse.
104      */

105     public void release()
106     {
107         super.release();
108         setIdExpr(null);
109         setFormBeanExpr(null);
110         setForwardExpr(null);
111         setMappingExpr(null);
112     }
113     
114     /**
115      * Process the start tag.
116      *
117      * @exception JspException if a JSP exception has occurred
118      */

119     public int doStartTag() throws JspException JavaDoc {
120         evaluateExpressions();
121         return (super.doStartTag());
122     }
123
124     /**
125      * Processes all attribute values which use the JSTL expression evaluation
126      * engine to determine their values.
127      *
128      * @exception JspException if a JSP exception has occurred
129      */

130     private void evaluateExpressions() throws JspException JavaDoc {
131         String JavaDoc string = null;
132
133         if ((string = EvalHelper.evalString("id", getIdExpr(),
134                                             this, pageContext)) != null)
135             setId(string);
136
137         if ((string = EvalHelper.evalString("formBean", getFormBeanExpr(),
138                                             this, pageContext)) != null)
139             setFormBean(string);
140
141         if ((string = EvalHelper.evalString("forward", getForwardExpr(),
142                                             this, pageContext)) != null)
143             setForward(string);
144
145         if ((string = EvalHelper.evalString("mapping", getMappingExpr(),
146                                             this, pageContext)) != null)
147             setMapping(string);
148     }
149 }
150
Popular Tags