KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > bridge > jsp > taglib > AbstractNodeProviderTag


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10 package org.mmbase.bridge.jsp.taglib;
11
12
13 import javax.servlet.jsp.JspTagException JavaDoc;
14
15 import org.mmbase.bridge.*;
16 import org.mmbase.bridge.jsp.taglib.util.Attribute;
17
18 /**
19  * A base class for tags which provide a node. The
20  * general attributes for a NodeProvider are
21  * <ul>
22  * <li> id: The identifier. Used as a key for the Context. If this
23  * attribute is missing, the Node variable will not be imported in the Context. </li>
24  * <li> jspvar: An identifier for a jsp variable available in the
25  * body. If this attribute is missing, no jsp-variable will be
26  * created.</li>
27  * </ul>
28  *
29  * @author Michiel Meeuwissen
30  * @author Kees Jongenburger
31  * @version $Id: AbstractNodeProviderTag.java,v 1.38 2006/07/17 15:38:47 johannes Exp $
32  */

33
34 abstract public class AbstractNodeProviderTag extends NodeReferrerTag implements NodeProvider {
35     // a node provider is a nodereferrer as well...
36
// this is especially useful for some extended classes (like 'relatednodes').
37

38     final protected NodeProviderHelper nodeHelper = new NodeProviderHelper(this); // no m.i. and there are more nodeprovider which cannot extend this, they can use the same trick.
39

40
41     protected Attribute fieldEscaper;
42
43     /**
44      * @since MMBase-1.8
45      */

46     public void setFieldescape(String JavaDoc e) throws JspTagException JavaDoc {
47         fieldEscaper = getAttribute(e);
48     }
49
50
51     public void setJspvar(String JavaDoc jv) {
52         nodeHelper.setJspvar(jv);
53     }
54
55     
56     public Node getNodeVar() {
57         return nodeHelper.getNodeVar();
58     }
59     
60
61     protected void setNodeVar(Node node) {
62         nodeHelper.setNodeVar(node);
63     }
64
65     /**
66      * @since MMBase-1.8
67      */

68     public void setCommitonclose(String JavaDoc c) throws JspTagException JavaDoc {
69         nodeHelper.setCommitonclose(c);
70     }
71     
72     /**
73      * Fill the jsp and context vars
74      *
75      */

76
77     protected void fillVars() throws JspTagException JavaDoc {
78         nodeHelper.fillVars();
79     }
80                
81     public Query getGeneratingQuery() throws JspTagException JavaDoc {
82         return nodeHelper.getGeneratingQuery();
83     }
84
85
86     /**
87     * Does everything needed on the afterbody tag of every
88     * NodeProvider. Normally this function would be overrided with
89     * one that has to call super.doAfterBody(). But not all servlet
90     * engines to call this function if there is no body. So, in that
91     * case it should be called from doEndTag, if the tag can do
92     * something without a body.
93     **/

94     public int doAfterBody() throws JspTagException JavaDoc {
95         return nodeHelper.doAfterBody();
96     }
97     
98     public int doEndTag() throws JspTagException JavaDoc {
99         super.doEndTag();
100         return nodeHelper.doEndTag();
101     }
102
103     public void doFinally() {
104         super.doFinally();
105         nodeHelper.doFinally();
106     }
107 }
108
Popular Tags