1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.strutsel.taglib.html;
19
20 import org.apache.struts.taglib.html.HtmlTag;
21 import org.apache.strutsel.taglib.utils.EvalHelper;
22
23 import javax.servlet.jsp.JspException;
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. <p> This class
28 * is a subclass of the class <code>org.apache.struts.taglib.html.HtmlTag</code>
29 * which provides most of the described functionality. This subclass allows
30 * all attribute values to be specified as expressions utilizing the
31 * JavaServer Pages Standard Library expression language.
32 *
33 * @version $Rev: 376779 $
34 */
35 public class ELHtmlTag extends HtmlTag {
36 /***
37 * Instance variable mapped to "lang" tag attribute. (Mapping set in
38 * associated BeanInfo class.)
39 */
40 private String langExpr;
41
42 /***
43 * Instance variable mapped to "xhtml" tag attribute. (Mapping set in
44 * associated BeanInfo class.)
45 */
46 private String xhtmlExpr;
47
48 /***
49 * Getter method for "lang" tag attribute. (Mapping set in associated
50 * BeanInfo class.)
51 */
52 public String getLangExpr() {
53 return (langExpr);
54 }
55
56 /***
57 * Getter method for "xhtml" tag attribute. (Mapping set in associated
58 * BeanInfo class.)
59 */
60 public String getXhtmlExpr() {
61 return (xhtmlExpr);
62 }
63
64 /***
65 * Setter method for "lang" tag attribute. (Mapping set in associated
66 * BeanInfo class.)
67 */
68 public void setLangExpr(String langExpr) {
69 this.langExpr = langExpr;
70 }
71
72 /***
73 * Setter method for "xhtml" tag attribute. (Mapping set in associated
74 * BeanInfo class.)
75 */
76 public void setXhtmlExpr(String xhtmlExpr) {
77 this.xhtmlExpr = xhtmlExpr;
78 }
79
80 /***
81 * Resets attribute values for tag reuse.
82 */
83 public void release() {
84 super.release();
85 setLangExpr(null);
86 setXhtmlExpr(null);
87 }
88
89 /***
90 * Process the start tag.
91 *
92 * @throws JspException if a JSP exception has occurred
93 */
94 public int doStartTag() throws JspException {
95 evaluateExpressions();
96
97 return (super.doStartTag());
98 }
99
100 /***
101 * Processes all attribute values which use the JSTL expression evaluation
102 * engine to determine their values.
103 *
104 * @throws JspException if a JSP exception has occurred
105 */
106 private void evaluateExpressions()
107 throws JspException {
108 Boolean bool = null;
109 String string = null;
110
111 if ((bool =
112 EvalHelper.evalBoolean("lang", getLangExpr(), this, pageContext)) != null) {
113 setLang(bool.booleanValue());
114 }
115
116 if ((bool =
117 EvalHelper.evalBoolean("xhtml", getXhtmlExpr(), this,
118 pageContext)) != null) {
119 setXhtml(bool.booleanValue());
120 }
121 }
122 }