001: /*
002: * $Id: ELHtmlTag.java 471754 2006-11-06 14:55:09Z husted $
003: *
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021: package org.apache.strutsel.taglib.html;
022:
023: import org.apache.struts.taglib.html.HtmlTag;
024: import org.apache.strutsel.taglib.utils.EvalHelper;
025:
026: import javax.servlet.jsp.JspException;
027:
028: /**
029: * Renders an HTML <html> element with appropriate language attributes if
030: * there is a current Locale available in the user's session. <p> This class
031: * is a subclass of the class <code>org.apache.struts.taglib.html.HtmlTag</code>
032: * which provides most of the described functionality. This subclass allows
033: * all attribute values to be specified as expressions utilizing the
034: * JavaServer Pages Standard Library expression language.
035: *
036: * @version $Rev: 471754 $
037: */
038: public class ELHtmlTag extends HtmlTag {
039: /**
040: * Instance variable mapped to "lang" tag attribute. (Mapping set in
041: * associated BeanInfo class.)
042: */
043: private String langExpr;
044:
045: /**
046: * Instance variable mapped to "xhtml" tag attribute. (Mapping set in
047: * associated BeanInfo class.)
048: */
049: private String xhtmlExpr;
050:
051: /**
052: * Getter method for "lang" tag attribute. (Mapping set in associated
053: * BeanInfo class.)
054: */
055: public String getLangExpr() {
056: return (langExpr);
057: }
058:
059: /**
060: * Getter method for "xhtml" tag attribute. (Mapping set in associated
061: * BeanInfo class.)
062: */
063: public String getXhtmlExpr() {
064: return (xhtmlExpr);
065: }
066:
067: /**
068: * Setter method for "lang" tag attribute. (Mapping set in associated
069: * BeanInfo class.)
070: */
071: public void setLangExpr(String langExpr) {
072: this .langExpr = langExpr;
073: }
074:
075: /**
076: * Setter method for "xhtml" tag attribute. (Mapping set in associated
077: * BeanInfo class.)
078: */
079: public void setXhtmlExpr(String xhtmlExpr) {
080: this .xhtmlExpr = xhtmlExpr;
081: }
082:
083: /**
084: * Resets attribute values for tag reuse.
085: */
086: public void release() {
087: super .release();
088: setLangExpr(null);
089: setXhtmlExpr(null);
090: }
091:
092: /**
093: * Process the start tag.
094: *
095: * @throws JspException if a JSP exception has occurred
096: */
097: public int doStartTag() throws JspException {
098: evaluateExpressions();
099:
100: return (super .doStartTag());
101: }
102:
103: /**
104: * Processes all attribute values which use the JSTL expression evaluation
105: * engine to determine their values.
106: *
107: * @throws JspException if a JSP exception has occurred
108: */
109: private void evaluateExpressions() throws JspException {
110: Boolean bool = null;
111: String string = null;
112:
113: if ((bool = EvalHelper.evalBoolean("lang", getLangExpr(), this ,
114: pageContext)) != null) {
115: setLang(bool.booleanValue());
116: }
117:
118: if ((bool = EvalHelper.evalBoolean("xhtml", getXhtmlExpr(),
119: this, pageContext)) != null) {
120: setXhtml(bool.booleanValue());
121: }
122: }
123: }
|