KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > cofax > taglibs > FooterTag


1 /*
2  * FooterTag is part of the Cofax content management system library.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Please see http://www.cofax.org for contact information and other related informaion.
19  *
20  * $Header: /cvsroot/cofax/cofax/src/org/cofax/taglibs/FooterTag.java,v 1.3.2.1 2006/12/11 16:27:38 fxrobin Exp $
21  */

22 package org.cofax.taglibs;
23
24 import javax.servlet.jsp.*;
25 import javax.servlet.jsp.tagext.*;
26 import java.io.*;
27
28 /**
29  * FooterTag is a child tag to ExecuteTag, which in turn is a child tag of
30  * PackageTag. A FooterTag allows access to the last row of a PackageTag's
31  * results to display the end of a table for example. This tag is used in
32  * concert with HeaderTag, RepeatTag, and NoRowTag.
33  *
34  * Note that this tag returns SKIP_BODY if no rows are returned from the
35  * PackageTag
36  */

37 public class FooterTag extends BodyTagSupport {
38
39     PackageTag parent;
40
41     /**
42      * Display the footer format if got data return from the packageTag
43      */

44     public int doStartTag() {
45
46         parent = (PackageTag) findAncestorWithClass(this, PackageTag.class);
47         // check for null, existing row with condition to eval only 1 time
48
if ((parent != null) && (!parent.getNoRows())) {
49             return EVAL_BODY_TAG;
50         } else {
51             return SKIP_BODY;
52         }
53
54     }
55
56     /**
57      * Eval the footer format that normally is HTML form or JSP.
58      */

59     public int doAfterBody() throws JspException {
60
61         BodyContent body = getBodyContent();
62         try {
63             body.writeOut(getPreviousOut());
64         } catch (IOException e) {
65             parent.printMessage("Error in IO body footer" + e);
66         }
67         body.clearBody();
68         return SKIP_BODY;
69
70     }
71
72     /**
73      * Ends this Tag run.
74      */

75     public int doEndTag() {
76         return EVAL_PAGE;
77     }
78
79 } // end FooterTag
80

81
Popular Tags