KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.io.IOException JavaDoc;
13
14 import javax.servlet.jsp.JspTagException JavaDoc;
15 import javax.servlet.jsp.tagext.BodyTag JavaDoc;
16
17 import org.mmbase.bridge.jsp.taglib.util.Attribute;
18 import org.mmbase.bridge.Node;
19
20 /**
21  * Needs to live under a ListRelationsTag
22  *
23  * @author Michiel Meeuwissen
24  * @version $Id: RelatedNodeTag.java,v 1.18 2006/07/17 15:38:47 johannes Exp $
25  */

26 public class RelatedNodeTag extends AbstractNodeProviderTag implements BodyTag JavaDoc {
27
28     private Attribute listRelationsId = Attribute.NULL;
29
30     public void setListrelations(String JavaDoc l) throws JspTagException JavaDoc {
31         listRelationsId = getAttribute(l);
32     }
33
34     public int doStartTag() throws JspTagException JavaDoc{
35         // get the parent ListRelationsTag
36
ListRelationsTag lr = (ListRelationsTag) findParentTag(ListRelationsTag.class, (String JavaDoc) listRelationsId.getValue(this));
37
38
39         Node node = lr.getRelatedNode();
40         setNodeVar(node);
41         // if direct parent is a Formatter Tag, then communicate
42
FormatterTag f = (FormatterTag) findParentTag(FormatterTag.class, null, false);
43         if (f!= null && f.wantXML() && node != null) {
44             f.getGenerator().add(node);
45             f.setCloud(node.getCloud());
46         }
47         fillVars();
48         return EVAL_BODY_BUFFERED;
49     }
50
51     public void doInitBody() throws JspTagException JavaDoc {
52     }
53
54     /**
55     * this method writes the content of the body back to the jsp page
56     **/

57     public int doAfterBody() throws JspTagException JavaDoc {
58         super.doAfterBody();
59         if (bodyContent != null) {
60             try {
61                 bodyContent.writeOut(bodyContent.getEnclosingWriter());
62             } catch (IOException JavaDoc ioe){
63                 throw new TaglibException(ioe);
64             }
65         }
66         return SKIP_BODY;
67     }
68
69 }
70
Popular Tags