KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > taglibs > standard > tag > common > xml > ParamSupport


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.common.xml;
18
19 import javax.servlet.jsp.JspException JavaDoc;
20 import javax.servlet.jsp.JspTagException JavaDoc;
21 import javax.servlet.jsp.tagext.BodyTagSupport JavaDoc;
22 import javax.servlet.jsp.tagext.Tag JavaDoc;
23
24 import org.apache.taglibs.standard.resources.Resources;
25
26 /**
27  * <p>Support for tag handlers for &lt;param&gt;, the XML parameter
28  * subtag for &lt;transformt&lt;.</p>
29  *
30  * @see TransformSupport
31  * @author Shawn Bayern
32  */

33
34 public abstract class ParamSupport extends BodyTagSupport JavaDoc {
35
36     //*********************************************************************
37
// Protected state
38

39     protected String JavaDoc name; // 'name' attribute
40
protected Object JavaDoc value; // 'value' attribute
41

42     //*********************************************************************
43
// Constructor and initialization
44

45     public ParamSupport() {
46     super();
47     init();
48     }
49
50     private void init() {
51     name = null;
52     value = null;
53     }
54
55
56     //*********************************************************************
57
// Tag logic
58

59     // simply send our name and value to our parent <transform> tag
60
public int doEndTag() throws JspException JavaDoc {
61     Tag JavaDoc t = findAncestorWithClass(this, TransformSupport.class);
62     if (t == null)
63         throw new JspTagException JavaDoc(
64         Resources.getMessage("PARAM_OUTSIDE_TRANSFORM"));
65     TransformSupport parent = (TransformSupport) t;
66
67     Object JavaDoc value = this.value;
68     if (value == null) {
69             if (bodyContent == null || bodyContent.getString() == null)
70                 value = "";
71             else
72                 value = bodyContent.getString().trim();
73         }
74     parent.addParameter(name, value);
75     return EVAL_PAGE;
76     }
77
78     // Releases any resources we may have (or inherit)
79
public void release() {
80     init();
81     }
82 }
83
Popular Tags