KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > taglibs > standard > tag > el > core > OutTag


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.taglibs.standard.tag.el.core;
18
19 import javax.servlet.jsp.JspException JavaDoc;
20
21 import org.apache.taglibs.standard.tag.common.core.NullAttributeException;
22 import org.apache.taglibs.standard.tag.common.core.OutSupport;
23
24 /**
25  * <p>A handler for &lt;out&gt;, which redirects the browser to a
26  * new URL.
27  *
28  * @author Shawn Bayern
29  */

30
31 public class OutTag extends OutSupport {
32
33     //*********************************************************************
34
// 'Private' state (implementation details)
35

36     private String JavaDoc value_; // stores EL-based property
37
private String JavaDoc default_; // stores EL-based property
38
private String JavaDoc escapeXml_; // stores EL-based property
39

40
41     //*********************************************************************
42
// Constructor
43

44     public OutTag() {
45         super();
46         init();
47     }
48
49
50     //*********************************************************************
51
// Tag logic
52

53     // evaluates expression and chains to parent
54
public int doStartTag() throws JspException JavaDoc {
55
56         // evaluate any expressions we were passed, once per invocation
57
evaluateExpressions();
58
59     // chain to the parent implementation
60
return super.doStartTag();
61     }
62
63
64     // Releases any resources we may have (or inherit)
65
public void release() {
66         super.release();
67         init();
68     }
69
70
71     //*********************************************************************
72
// Accessor methods
73

74     public void setValue(String JavaDoc value_) {
75         this.value_ = value_;
76     }
77
78     public void setDefault(String JavaDoc default_) {
79         this.default_ = default_;
80     }
81
82     public void setEscapeXml(String JavaDoc escapeXml_) {
83         this.escapeXml_ = escapeXml_;
84     }
85
86
87     //*********************************************************************
88
// Private (utility) methods
89

90     // (re)initializes state (during release() or construction)
91
private void init() {
92         // null implies "no expression"
93
value_ = default_ = escapeXml_ = null;
94     }
95
96     /* Evaluates expressions as necessary */
97     private void evaluateExpressions() throws JspException JavaDoc {
98     try {
99         value = ExpressionUtil.evalNotNull(
100             "out", "value", value_, Object JavaDoc.class, this, pageContext);
101     } catch (NullAttributeException ex) {
102         // explicitly allow 'null' for value
103
value = null;
104     }
105     try {
106         def = (String JavaDoc) ExpressionUtil.evalNotNull(
107             "out", "default", default_, String JavaDoc.class, this, pageContext);
108     } catch (NullAttributeException ex) {
109         // explicitly allow 'null' for def
110
def = null;
111     }
112     escapeXml = true;
113     Boolean JavaDoc escape = ((Boolean JavaDoc) ExpressionUtil.evalNotNull(
114         "out", "escapeXml", escapeXml_, Boolean JavaDoc.class, this, pageContext));
115     if (escape != null)
116         escapeXml = escape.booleanValue();
117     }
118 }
119
Popular Tags