KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jivesoftware > admin > SubSidebarTag


1 /**
2  * $RCSfile: SubSidebarTag.java,v $
3  * $Revision: 1.3 $
4  * $Date: 2004/11/10 20:13:33 $
5  *
6  * Copyright (C) 2004 Jive Software. All rights reserved.
7  *
8  * This software is published under the terms of the GNU Public License (GPL),
9  * a copy of which is included in this distribution.
10  */

11
12 package org.jivesoftware.admin;
13
14 import javax.servlet.jsp.JspException JavaDoc;
15 import javax.servlet.jsp.JspTagException JavaDoc;
16
17 /**
18  * <p>A simple tag to gather its body content and pass it to the parent tag. This tag must be used
19  * as a child of the {@link SidebarTag}.</p>
20  *
21  * <p>Sample usage:<ul><tt>
22  *
23  * &lt;jive:sidebar bean="jivepageinfo"&gt; <br>
24  * &nbsp;&nbsp;&nbsp;&lt;a HREF="[url]" title="[description]"&gt;[name]&lt;/a&gt; <br>
25  * &nbsp;&nbsp;&nbsp;&lt;jive:subsidebar&gt; <br>
26  * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;a HREF="[url]"&gt;[name]&lt;/a&gt; <br>
27  * &nbsp;&nbsp;&nbsp;&lt;/jive:subsidebar&gt; <br>
28  * &lt;/jive:sidebar&gt;</tt></ul></p>
29  *
30  * <p>Note, this class has no attributes.</p>
31  */

32 public class SubSidebarTag extends SidebarTag {
33
34     private SidebarTag parent;
35     private String JavaDoc body;
36
37     /**
38      * Returns the body content of this tag.
39      */

40     public String JavaDoc getBody() {
41         return body;
42     }
43
44     /**
45      * Sets the body content of this tag.
46      */

47     public void setBody(String JavaDoc body) {
48         this.body = body;
49     }
50
51     /**
52      * Looks for the parent SidebarTag class, throws an error if not found. If found,
53      * {@link #EVAL_BODY_BUFFERED} is returned.
54      *
55      * @return {@link #EVAL_BODY_BUFFERED} if no errors.
56      * @throws javax.servlet.jsp.JspException if a parent SidebarTag is not found.
57      */

58     public int doStartTag() throws JspException JavaDoc {
59         // The I18nTag should be our parent Tag
60
parent = (SidebarTag)findAncestorWithClass(this, SidebarTag.class);
61
62         // If I18nTag was not our parent, throw Exception
63
if (parent == null) {
64             throw new JspTagException JavaDoc("SubSidebarTag with out a parent which is expected to be a SidebarTag");
65         }
66         return EVAL_BODY_BUFFERED;
67     }
68
69     /**
70      * Sets the 'body' property to be equal to the body content of this tag. Calls the
71      * {@link SidebarTag#setSubSidebar(SubSidebarTag)} method of the parent tag.
72      * @return {@link #EVAL_PAGE}
73      * @throws JspException if an error occurs.
74      */

75     public int doEndTag() throws JspException JavaDoc {
76         setBody(bodyContent.getString());
77         parent.setSubSidebar(this);
78         return EVAL_PAGE;
79     }
80 }
Popular Tags