1 /*
2 * $Id: ELBaseTag.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.BaseTag;
22 import javax.servlet.jsp.JspException;
23 import org.apache.strutsel.taglib.utils.EvalHelper;
24
25 /**
26 * Renders an HTML <base> element with an href
27 * attribute pointing to the absolute location of the enclosing JSP page. This
28 * tag is only valid when nested inside a head tag body. The presence
29 * of this tag allows the browser to resolve relative URL's to images,
30 * CSS stylesheets and other resources in a manner independent of the URL
31 * used to call the ActionServlet.
32 *<p>
33 * This class is a subclass of the class
34 * <code>org.apache.struts.taglib.html.BaseTag</code> which provides most of
35 * the described functionality. This subclass allows all attribute values to
36 * be specified as expressions utilizing the JavaServer Pages Standard Library
37 * expression language.
38 *
39 * @version $Rev: 54933 $
40 */
41 public class ELBaseTag extends BaseTag {
42
43 /**
44 * Instance variable mapped to "target" tag attribute.
45 * (Mapping set in associated BeanInfo class.)
46 */
47 private String targetExpr;
48 /**
49 * Instance variable mapped to "server" tag attribute.
50 * (Mapping set in associated BeanInfo class.)
51 */
52 private String serverExpr;
53
54 /**
55 * Getter method for "target" tag attribute.
56 * (Mapping set in associated BeanInfo class.)
57 */
58 public String getTargetExpr() { return (targetExpr); }
59 /**
60 * Getter method for "server" tag attribute.
61 * (Mapping set in associated BeanInfo class.)
62 */
63 public String getServerExpr() { return (serverExpr); }
64
65 /**
66 * Setter method for "target" tag attribute.
67 * (Mapping set in associated BeanInfo class.)
68 */
69 public void setTargetExpr(String targetExpr) { this.targetExpr = targetExpr; }
70 /**
71 * Setter method for "server" tag attribute.
72 * (Mapping set in associated BeanInfo class.)
73 */
74 public void setServerExpr(String serverExpr) { this.serverExpr = serverExpr; }
75
76 /**
77 * Resets attribute values for tag reuse.
78 */
79 public void release()
80 {
81 super.release();
82 setTargetExpr(null);
83 setServerExpr(null);
84 }
85
86 /**
87 * Process the start tag.
88 *
89 * @exception JspException if a JSP exception has occurred
90 */
91 public int doStartTag() throws JspException {
92 evaluateExpressions();
93 return (super.doStartTag());
94 }
95
96 /**
97 * Processes all attribute values which use the JSTL expression evaluation
98 * engine to determine their values.
99 *
100 * @exception JspException if a JSP exception has occurred
101 */
102 private void evaluateExpressions() throws JspException {
103 String string = null;
104
105 if ((string = EvalHelper.evalString("target", getTargetExpr(),
106 this, pageContext)) != null)
107 setTarget(string);
108
109 if ((string = EvalHelper.evalString("server", getServerExpr(),
110 this, pageContext)) != null)
111 setServer(string);
112 }
113 }