KickJava   Java API By Example, From Geeks To Geeks.

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


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.WindowURL;
12 import org.jboss.portal.server.plugins.mode.Mode;
13 import org.jboss.portal.server.plugins.windowstate.WindowState;
14
15 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
16 import javax.servlet.jsp.JspException JavaDoc;
17 import javax.servlet.jsp.JspWriter JavaDoc;
18 import javax.servlet.jsp.JspTagException JavaDoc;
19 import java.io.IOException JavaDoc;
20
21 /**
22  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
23  * @version $Revision: 1.2 $
24  */

25 public class URLTag extends TagSupport JavaDoc
26 {
27    /** Mode. */
28    private String JavaDoc mode;
29
30    /** Window state. */
31    private String JavaDoc windowState;
32
33    public String JavaDoc getMode()
34    {
35       return mode;
36    }
37
38    public void setMode(String JavaDoc mode)
39    {
40       this.mode = mode;
41    }
42
43    public String JavaDoc getWindowState()
44    {
45       return windowState;
46    }
47
48    public void setWindowState(String JavaDoc windowState)
49    {
50       this.windowState = windowState;
51    }
52
53    public int doStartTag() throws JspException JavaDoc
54    {
55       IterateTag other = (IterateTag)findAncestorWithClass(this, IterateTag.class);
56       try
57       {
58          WindowURL navURL = other.navURL;
59          if (mode != null)
60          {
61             navURL.setMode(Mode.create(mode));
62          }
63          else
64          {
65             navURL.setMode(null);
66          }
67          if (windowState != null)
68          {
69             navURL.setWindowState(WindowState.create(windowState));
70          }
71          else
72          {
73             navURL.setWindowState(null);
74          }
75          JspWriter JavaDoc writer = pageContext.getOut();
76          String JavaDoc url = other.resp.createURL(navURL, true);
77          writer.print(url);
78          return SKIP_BODY;
79       }
80       catch (IOException JavaDoc e)
81       {
82          throw new JspTagException JavaDoc(e);
83       }
84    }
85
86    public int doEndTag() throws JspException JavaDoc
87    {
88       return EVAL_PAGE;
89    }
90 }
91
Popular Tags