KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: ELPageTag.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.PageTag;
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 page context
27  * item as a scripting variable and a page scope bean.
28  *<p>
29  * This class is a subclass of the class
30  * <code>org.apache.struts.taglib.bean.PageTag</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 ELPageTag extends PageTag {
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 "property" tag attribute.
46      * (Mapping set in associated BeanInfo class.)
47      */

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

54     public String JavaDoc getIdExpr() { return (idExpr); }
55     /**
56      * Getter method for "property" tag attribute.
57      * (Mapping set in associated BeanInfo class.)
58      */

59     public String JavaDoc getPropertyExpr() { return (propertyExpr); }
60
61     /**
62      * Setter method for "id" tag attribute.
63      * (Mapping set in associated BeanInfo class.)
64      */

65     public void setIdExpr(String JavaDoc idExpr) { this.idExpr = idExpr; }
66     /**
67      * Setter method for "property" tag attribute.
68      * (Mapping set in associated BeanInfo class.)
69      */

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

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

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

98     private void evaluateExpressions() throws JspException JavaDoc {
99         String JavaDoc string = null;
100
101
102         if ((string = EvalHelper.evalString("id", getIdExpr(),
103                                             this, pageContext)) != null)
104             setId(string);
105
106         if ((string = EvalHelper.evalString("property", getPropertyExpr(),
107                                             this, pageContext)) != null)
108             setProperty(string);
109     }
110 }
111
Popular Tags