KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > strutsel > taglib > html > ELHtmlTag


1 /*
2  * $Id: ELHtmlTag.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.html;
20
21 import org.apache.struts.taglib.html.HtmlTag;
22 import javax.servlet.jsp.JspException JavaDoc;
23 import org.apache.strutsel.taglib.utils.EvalHelper;
24
25 /**
26  * Renders an HTML <html> element with appropriate language attributes if
27  * there is a current Locale available in the user's session.
28  *<p>
29  * This class is a subclass of the class
30  * <code>org.apache.struts.taglib.html.HtmlTag</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 ELHtmlTag extends HtmlTag {
38
39     /**
40      * Instance variable mapped to "lang" tag attribute.
41      * (Mapping set in associated BeanInfo class.)
42      */

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

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

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

59     public String JavaDoc getLangExpr() { return (langExpr); }
60     /**
61      * Getter method for "locale" tag attribute.
62      * (Mapping set in associated BeanInfo class.)
63      */

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

69     public String JavaDoc getXhtmlExpr() { return (xhtmlExpr); }
70
71     /**
72      * Setter method for "lang" tag attribute.
73      * (Mapping set in associated BeanInfo class.)
74      */

75     public void setLangExpr(String JavaDoc langExpr) { this.langExpr = langExpr; }
76     /**
77      * Setter method for "locale" tag attribute.
78      * (Mapping set in associated BeanInfo class.)
79      */

80     public void setLocaleExpr(String JavaDoc localeExpr) { this.localeExpr = localeExpr; }
81     /**
82      * Setter method for "xhtml" tag attribute.
83      * (Mapping set in associated BeanInfo class.)
84      */

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

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

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

114     private void evaluateExpressions() throws JspException JavaDoc {
115         Boolean JavaDoc bool = null;
116         String JavaDoc string = null;
117
118         if ((bool = EvalHelper.evalBoolean("lang", getLangExpr(),
119                                            this, pageContext)) != null)
120             setLang(bool.booleanValue());
121
122         if ((bool = EvalHelper.evalBoolean("locale", getLocaleExpr(),
123                                            this, pageContext)) != null)
124             setLocale(bool.booleanValue());
125
126         if ((bool = EvalHelper.evalBoolean("xhtml", getXhtmlExpr(),
127                                            this, pageContext)) != null)
128             setXhtml(bool.booleanValue());
129     }
130 }
131
Popular Tags