KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > core > theme > tag > basic > ExistTag


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.core.theme.tag.basic;
10
11 import org.jboss.portal.server.PortalRequest;
12 import org.jboss.portal.server.theme.PageHolder;
13 import org.jboss.portal.server.theme.Region;
14 import org.jboss.portal.server.theme.RegionSet;
15
16 import javax.servlet.jsp.JspException JavaDoc;
17 import javax.servlet.jsp.tagext.BodyTagSupport JavaDoc;
18 import javax.servlet.jsp.tagext.Tag JavaDoc;
19
20 /**
21  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
22  * @version $Revision: 1.2 $
23  */

24 public class ExistTag extends BodyTagSupport JavaDoc
25 {
26
27    private String JavaDoc region;
28
29    public String JavaDoc getRegion()
30    {
31       return region;
32    }
33
34    public void setRegion(String JavaDoc region)
35    {
36       this.region = region;
37    }
38
39    public int doStartTag() throws JspException JavaDoc
40    {
41       PortalRequest preq = (PortalRequest)pageContext.getRequest().getAttribute("REQ");
42       PageHolder page = (PageHolder)preq.getAttribute("PAGE");
43       RegionSet regions = page.getRegions();
44       Region region = regions.getRegion(this.region);
45       if (region != null)
46       {
47          return Tag.EVAL_BODY_INCLUDE;
48       }
49       else
50       {
51          return Tag.SKIP_BODY;
52       }
53    }
54 }
55
Popular Tags