Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/aendvari/tethys/tag/inset/IncludeTag.java


1   /*
2    * IncludeTag.java
3    *
4    * Copyright (c) 2001, 2002 Aendvari, Ltd. All Rights Reserved.
5    *
6    * See the file LICENSE for terms of use.
7    *
8    */
9   
10  package com.aendvari.tethys.tag.inset;
11  
12  import java.util.*;
13  import java.io.IOException;
14  
15  import javax.servlet.*;
16  import javax.servlet.http.*;
17  import javax.servlet.jsp.*;
18  import javax.servlet.jsp.tagext.*;
19  
20  import com.aendvari.common.model.*;
21  
22  import com.aendvari.tethys.context.*;
23  import com.aendvari.tethys.context.inset.*;
24  
25  import com.aendvari.tethys.tag.*;
26  
27  /**
28   * <p>Implementation class for the inset "include" tag.</p>
29   *
30   * @author  Scott Milne
31   *
32   */
33  
34  public class IncludeTag extends InsetBaseTag
35  {
36    /* Variables. */
37  
38    /** The name of the tag. */
39    protected String name;
40  
41  
42    /* Constructor */
43  
44    public IncludeTag()
45    {
46      super();
47  
48      name = null;
49    }
50  
51    /* Attributes */
52  
53    public void setName(String name) { this.name = name; }
54    public String getName() { return name; }
55  
56  
57  
58    /**
59     * Start the tag by keeping the body from evaluating.
60     *
61     */
62  
63    public int doStartTag() throws JspException
64    {
65      return SKIP_BODY;
66    }
67  
68    /**
69     * Process the end tag by including the inset.
70     *
71     */
72  
73    public int doEndTag() throws JspException
74    {
75      // display the inset
76      try
77      {
78        // set context to be name of inset
79        context = name;
80  
81        // establish tag context
82        establishInsetContext();
83  
84        // inset context is also inset definition
85        Inset inset = (Inset)insetContext;
86  
87        if (inset == null)
88        {
89          throw new JspTagException("IncludeTag: could not include inset \"" + name + "\"");
90        }
91  
92        // write the inset's content into the page
93        pageContext.getOut().write(inset.getContent());
94      }
95      // IOException or ServletException
96      catch (IOException exception)
97      {
98        throw new JspTagException("IncludeTag:" + exception.toString());
99      }
100 
101     return EVAL_PAGE;
102   }
103 
104 
105     /**
106      * Release all allocated resources.
107    *
108      */
109 
110     public void release()
111     {
112         super.release();
113 
114     name = null;
115     }
116 }
117