KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/taglib/DbNavNewButtonTag.java,v 1.26 2004/10/20 10:52:02 hkollmann Exp $
3  * $Revision: 1.26 $
4  * $Date: 2004/10/20 10:52:02 $
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.config.ResultSetVector;
27
28 import org.dbforms.event.eventtype.EventType;
29
30 import org.dbforms.util.Util;
31
32 import javax.servlet.jsp.JspException JavaDoc;
33
34
35
36 /**
37  * this tag renders an "new"-button.
38  *
39  * @author Joachim Peer
40  */

41 public class DbNavNewButtonTag extends DbBaseButtonTag
42    implements javax.servlet.jsp.tagext.TryCatchFinally JavaDoc {
43    private String JavaDoc destTable;
44
45    /** Holds value of property showAlwaysInFooter. */
46    private String JavaDoc showAlwaysInFooter = "true";
47
48    /**
49     * Sets the destTable
50     *
51     * @param destTable The destTable to set
52     */

53    public void setDestTable(String JavaDoc destTable) {
54       this.destTable = destTable;
55    }
56
57
58    /**
59     * Gets the destTable
60     *
61     * @return Returns a String
62     */

63    public String JavaDoc getDestTable() {
64       return destTable;
65    }
66
67
68    /**
69     * Setter for property showAlwaysInFooter.
70     *
71     * @param showAlwaysInFooter New value of property showAlwaysInFooter.
72     */

73    public void setShowAlwaysInFooter(String JavaDoc showAlwaysInFooter) {
74       this.showAlwaysInFooter = showAlwaysInFooter;
75    }
76
77
78    /**
79     * Getter for property showAlwaysInFooter.
80     *
81     * @return Value of property showAlwaysInFooter.
82     */

83    public String JavaDoc getShowAlwaysInFooter() {
84       return this.showAlwaysInFooter;
85    }
86
87
88    /**
89     * @see javax.servlet.jsp.tagext.TryCatchFinally#doCatch(java.lang.Throwable)
90     */

91    public void doCatch(Throwable JavaDoc t) throws Throwable JavaDoc {
92       throw t;
93    }
94
95
96    /**
97     * DOCUMENT ME!
98     */

99    public void doFinally() {
100       destTable = null;
101       showAlwaysInFooter = "true";
102       super.doFinally();
103    }
104
105
106    /**
107     * DOCUMENT ME!
108     *
109     * @return DOCUMENT ME!
110     *
111     * @throws javax.servlet.jsp.JspException DOCUMENT ME!
112     * @throws JspException DOCUMENT ME!
113     */

114    public int doStartTag() throws javax.servlet.jsp.JspException JavaDoc {
115       super.doStartTag();
116
117       if (getParentForm()
118                    .isFooterReached()
119                 && ResultSetVector.isNull(getParentForm().getResultSetVector())
120                 && !Util.getTrue(showAlwaysInFooter)) {
121          // 20030521 HKK: Bug fixing, thanks to Michael Slack!
122
return SKIP_BODY;
123       }
124
125       try {
126          StringBuffer JavaDoc tagBuf = new StringBuffer JavaDoc();
127
128          // Allow navNewButton to specify a table for insertion other than the
129
// parent table. (Contrib. John Madsen)
130
int tableId = ((destTable != null) && (destTable.length() != 0))
131                        ? getConfig()
132                             .getTableByName(destTable)
133                             .getId()
134                        : getTable()
135                             .getId();
136
137          String JavaDoc tagName = EventType.EVENT_NAVIGATION_TRANSFER_NEW + tableId
138                           + "_" + Integer.toString(getUniqueID());
139
140          if (getFollowUp() != null) {
141             tagBuf.append(getDataTag(tagName, "fu", getFollowUp()));
142          }
143
144          if (getFollowUpOnError() != null) {
145             tagBuf.append(getDataTag(tagName, "fue", getFollowUpOnError()));
146          }
147
148          tagBuf.append(getButtonBegin());
149          tagBuf.append(" name=\"");
150          tagBuf.append(tagName);
151          tagBuf.append(getButtonEnd());
152
153          pageContext.getOut()
154                     .write(tagBuf.toString());
155       } catch (java.io.IOException JavaDoc ioe) {
156          throw new JspException JavaDoc("IO Error: " + ioe.getMessage());
157       }
158
159       if (getChoosenFlavor() == FLAVOR_MODERN) {
160          return EVAL_BODY_BUFFERED;
161       } else {
162          return SKIP_BODY;
163       }
164    }
165 }
166
Popular Tags