KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dbforms > taglib > DbBaseHandlerFactory


1 /*
2  * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/taglib/DbBaseHandlerFactory.java,v 1.4 2004/08/19 20:10:50 hkollmann Exp $
3  * $Revision: 1.4 $
4  * $Date: 2004/08/19 20:10:50 $
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 org.dbforms.util.PageContextBuffer;
27
28 import javax.servlet.Servlet JavaDoc;
29 import javax.servlet.jsp.JspException JavaDoc;
30 import javax.servlet.jsp.PageContext JavaDoc;
31 import javax.servlet.jsp.tagext.BodyTagSupport JavaDoc;
32 import javax.servlet.jsp.tagext.Tag JavaDoc;
33
34
35
36 /**
37  * Factory class to render buttons. Can be used to include a button into
38  * another tag. see DbFilterTag for example
39  *
40  * @author Henner Kollmann
41  */

42 public class DbBaseHandlerFactory {
43    private DbBaseHandlerTag tag;
44    private PageContextBuffer pageContext;
45
46    /**
47     * Creates a new DbBaseButtonFactory object.
48     *
49     * @param parentContext parentContext to send to new tag
50     * @param parent parent tag to send to new tag
51     * @param clazz the button class to generate
52     *
53     * @throws JspException exception
54     */

55    public DbBaseHandlerFactory(PageContext JavaDoc parentContext,
56                                BodyTagSupport JavaDoc parent,
57                                Class JavaDoc clazz) throws JspException JavaDoc {
58       try {
59          tag = (DbBaseHandlerTag) clazz.newInstance();
60          pageContext = new PageContextBuffer();
61          pageContext.initialize((Servlet JavaDoc) parentContext.getPage(),
62                                 parentContext.getRequest(),
63                                 parentContext.getResponse(), null, true, 0, true);
64          tag.setPageContext(pageContext);
65          tag.setParent(parent);
66       } catch (Exception JavaDoc e) {
67          throw new JspException JavaDoc(e);
68       }
69    }
70
71    /**
72     * gets the generated button tag
73     *
74     * @return the button tag
75     */

76    public DbBaseHandlerTag getTag() {
77       return tag;
78    }
79
80
81    /**
82     * renders the generated button tag into StringBuffer
83     *
84     * @return the StringBuffer
85     *
86     * @throws JspException thrown exception
87     */

88    public StringBuffer JavaDoc render() throws JspException JavaDoc {
89       if (tag.doStartTag() != Tag.SKIP_BODY) {
90          tag.doEndTag();
91       }
92
93       return pageContext.getBuffer();
94    }
95 }
96
Popular Tags