View Javadoc

1   /*
2    * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/taglib/DbFooterTag.java,v 1.17 2005/11/28 21:10:56 hkollmann Exp $
3    * $Revision: 1.17 $
4    * $Date: 2005/11/28 21:10:56 $
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  package org.dbforms.taglib;
24  import javax.servlet.jsp.JspException;
25  
26  
27  
28  /***
29   * this tag renders a Footer-tag. it is supposed to be nested within a
30   * DbFormTag. because this tag is nested within a DbFormTag it is invoked
31   * every time the parent dbFormTag gets evaluated, but it gets only rendered
32   * at the end of the last evalation-loop.
33   *
34   * @author Joachim Peer
35   */
36  public class DbFooterTag extends AbstractDbBaseHandlerTag {
37     /***
38      * DOCUMENT ME!
39      *
40      * @return DOCUMENT ME!
41      *
42      * @throws JspException DOCUMENT ME!
43      */
44     public int doAfterBody() throws JspException {
45        return SKIP_BODY; // a footer gets onle 1 time rendered
46     }
47  
48  
49     /***
50      * DOCUMENT ME!
51      *
52      * @return DOCUMENT ME!
53      *
54      * @throws JspException DOCUMENT ME!
55      */
56     public int doEndTag() throws JspException {
57        try {
58           if (bodyContent != null) {
59              bodyContent.writeOut(bodyContent.getEnclosingWriter());
60              bodyContent.clearBody(); // 2002116-HKK: workaround for duplicate rows in Tomcat 4.1
61           }
62        } catch (java.io.IOException e) {
63           throw new JspException("IO Error: " + e.getMessage());
64        }
65  
66        return EVAL_PAGE;
67     }
68  
69  
70     /***
71      * DOCUMENT ME!
72      *
73      * @return DOCUMENT ME!
74      */
75     public int doStartTag() {
76        if (getParentForm().isFooterReached()) {
77           return EVAL_BODY_BUFFERED;
78        } else {
79           return SKIP_BODY;
80        }
81     }
82  }