View Javadoc

1   /*
2    * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/taglib/TemplateBasedirTag.java,v 1.15 2006/01/13 13:38:51 hkollmann Exp $
3    * $Revision: 1.15 $
4    * $Date: 2006/01/13 13:38:51 $
5    *
6    * DbForms - a Rapid Application Development Framework
7    * Copyright (C) 2001 Joachim Peer <joepeer@excite.com>
8    *
9    * This library is free software; you can redistribute it and/or
10   * modify it under the terms of the GNU Lesser General Public
11   * License as published by the Free Software Foundation; either
12   * version 2.1 of the License, or (at your option) any later version.
13   *
14   * This library is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17   * Lesser General Public License for more details.
18   *
19   * You should have received a copy of the GNU Lesser General Public
20   * License along with this library; if not, write to the Free Software
21   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
22   */
23  
24  package org.dbforms.taglib;
25  
26  import java.io.*;
27  
28  import javax.servlet.jsp.JspException;
29  
30  
31  
32  /***
33   * Renders an dbforms style tag
34   *
35   * @author Joe Peer
36   */
37  public class TemplateBasedirTag extends AbstractScriptHandlerTag
38     implements javax.servlet.jsp.tagext.TryCatchFinally {
39     private String baseDir;
40  
41     /***
42      * DOCUMENT ME!
43      *
44      * @param pageContext DOCUMENT ME!
45      */
46     public void setPageContext(final javax.servlet.jsp.PageContext pageContext) {
47        super.setPageContext(pageContext);
48        this.baseDir = (String) pageContext.getRequest()
49                                           .getAttribute("baseDir");
50     }
51  
52  
53     /***
54      * DOCUMENT ME!
55      *
56      * @return DOCUMENT ME!
57      *
58      * @throws JspException DOCUMENT ME!
59      */
60     public int doEndTag() throws JspException {
61        try {
62           StringBuffer buf = new StringBuffer();
63           buf.append(baseDir);
64           pageContext.getOut()
65                      .flush();
66           pageContext.getOut()
67                      .write(buf.toString());
68        } catch (IOException ioe) {
69           throw new JspException("Problem including template end - "
70                                  + ioe.toString());
71        }
72  
73        return EVAL_PAGE;
74     }
75  
76  
77     /***
78      * DOCUMENT ME!
79      */
80     public void doFinally() {
81        baseDir = null;
82     }
83  
84  
85     /***
86      * DOCUMENT ME!
87      *
88      * @return DOCUMENT ME!
89      *
90      * @throws JspException DOCUMENT ME!
91      */
92     public int doStartTag() throws JspException {
93        return SKIP_BODY;
94     }
95  }