KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/taglib/DbGotoButtonTag.java,v 1.22 2004/08/18 12:26:07 hkollmann Exp $
3  * $Revision: 1.22 $
4  * $Date: 2004/08/18 12:26:07 $
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.event.eventtype.EventType;
27
28 import org.dbforms.util.Util;
29
30 import javax.servlet.jsp.JspException JavaDoc;
31
32
33
34 /**
35  * <p>
36  * this tag renders a Goto-button.
37  * </p>
38  *
39  * @author Joachim Peer
40  */

41 public class DbGotoButtonTag extends DbBaseButtonTag
42    implements javax.servlet.jsp.tagext.TryCatchFinally JavaDoc {
43    private String JavaDoc childField;
44    private String JavaDoc destPos;
45    private String JavaDoc destTable;
46    private String JavaDoc destination;
47    private String JavaDoc keyToDestPos;
48    private String JavaDoc keyToKeyToDestPos;
49    private String JavaDoc parentField;
50    private String JavaDoc singleRow = "false";
51
52    /**
53     * DOCUMENT ME!
54     *
55     * @param string
56     */

57    public void setChildField(String JavaDoc string) {
58       childField = string;
59    }
60
61
62    /**
63     * DOCUMENT ME!
64     *
65     * @return
66     */

67    public String JavaDoc getChildField() {
68       return childField;
69    }
70
71
72    /**
73     * DOCUMENT ME!
74     *
75     * @param destPos DOCUMENT ME!
76     */

77    public void setDestPos(String JavaDoc destPos) {
78       this.destPos = destPos;
79    }
80
81
82    /**
83     * DOCUMENT ME!
84     *
85     * @return DOCUMENT ME!
86     */

87    public String JavaDoc getDestPos() {
88       return destPos;
89    }
90
91
92    /**
93     * DOCUMENT ME!
94     *
95     * @param destTable DOCUMENT ME!
96     */

97    public void setDestTable(String JavaDoc destTable) {
98       this.destTable = destTable;
99    }
100
101
102    /**
103     * DOCUMENT ME!
104     *
105     * @return DOCUMENT ME!
106     */

107    public String JavaDoc getDestTable() {
108       return destTable;
109    }
110
111
112    /**
113     * DOCUMENT ME!
114     *
115     * @param destination DOCUMENT ME!
116     */

117    public void setDestination(String JavaDoc destination) {
118       this.destination = destination;
119    }
120
121
122    /**
123     * DOCUMENT ME!
124     *
125     * @return DOCUMENT ME!
126     */

127    public String JavaDoc getDestination() {
128       return destination;
129    }
130
131
132    /**
133     * DOCUMENT ME!
134     *
135     * @param keyToDestPos DOCUMENT ME!
136     */

137    public void setKeyToDestPos(String JavaDoc keyToDestPos) {
138       this.keyToDestPos = keyToDestPos;
139    }
140
141
142    /**
143     * DOCUMENT ME!
144     *
145     * @return DOCUMENT ME!
146     */

147    public String JavaDoc getKeyToDestPos() {
148       return keyToDestPos;
149    }
150
151
152    /**
153     * DOCUMENT ME!
154     *
155     * @param keyToKeyToDestPos DOCUMENT ME!
156     */

157    public void setKeyToKeyToDestPos(String JavaDoc keyToKeyToDestPos) {
158       this.keyToKeyToDestPos = keyToKeyToDestPos;
159    }
160
161
162    /**
163     * DOCUMENT ME!
164     *
165     * @return DOCUMENT ME!
166     */

167    public String JavaDoc getKeyToKeyToDestPos() {
168       return keyToKeyToDestPos;
169    }
170
171
172    /**
173     * DOCUMENT ME!
174     *
175     * @param string
176     */

177    public void setParentField(String JavaDoc string) {
178       parentField = string;
179    }
180
181
182    /**
183     * DOCUMENT ME!
184     *
185     * @return
186     */

187    public String JavaDoc getParentField() {
188       return parentField;
189    }
190
191
192    /**
193     * DOCUMENT ME!
194     *
195     * @param string
196     */

197    public void setSingleRow(String JavaDoc string) {
198       singleRow = string;
199    }
200
201
202    /**
203     * DOCUMENT ME!
204     *
205     * @return the attribute
206     */

207    public String JavaDoc getSingleRow() {
208       return singleRow;
209    }
210
211
212    /**
213     * @see javax.servlet.jsp.tagext.TryCatchFinally#doCatch(java.lang.Throwable)
214     */

215    public void doCatch(Throwable JavaDoc t) throws Throwable JavaDoc {
216       throw t;
217    }
218
219
220    /**
221     * DOCUMENT ME!
222     */

223    public void doFinally() {
224       destination = null;
225       destTable = null;
226       destPos = null;
227       keyToDestPos = null;
228       keyToKeyToDestPos = null;
229       singleRow = "false";
230       super.doFinally();
231    }
232
233
234    /**
235     * DOCUMENT ME!
236     *
237     * @return DOCUMENT ME!
238     *
239     * @throws javax.servlet.jsp.JspException DOCUMENT ME!
240     * @throws JspException DOCUMENT ME!
241     */

242    public int doStartTag() throws javax.servlet.jsp.JspException JavaDoc {
243       super.doStartTag();
244
245       try {
246          String JavaDoc tagName = EventType.EVENT_NAVIGATION_TRANSFER_GOTO
247                           + ((getTable() != null) ? getTable()
248                                                        .getId()
249                                                   : (-1)) + "_"
250                           + Integer.toString(getUniqueID());
251
252          StringBuffer JavaDoc tagBuf = new StringBuffer JavaDoc();
253
254          // mask destination as "fu" (FollowUp), so that we can use standard-event dispatching facilities
255
// from Controller and dont have to invent something new!
256
// #checkme: should we rename destination to followUp ?
257
if (destination != null) {
258             tagBuf.append(getDataTag(tagName, "fu", destination));
259          }
260
261          if (destTable != null) {
262             tagBuf.append(getDataTag(tagName, "destTable", destTable));
263          }
264
265          // 2004-01-13 HKK: Fix encoding
266
// 2004-05-20 HKK: destPos should be already encoded! So do not encode it twice!
267
// tagBuf.append(getDataTag(tagName, "destPos", Util.encode(destPos, pageContext.getRequest().getCharacterEncoding())));
268
tagBuf.append(getDataTag(tagName, "destPos", destPos));
269          tagBuf.append(getDataTag(tagName, "keyToDestPos",
270                                   Util.encode(keyToDestPos,
271                                               pageContext.getRequest().getCharacterEncoding())));
272          tagBuf.append(getDataTag(tagName, "keyToKeyToDestPos",
273                                   Util.encode(keyToKeyToDestPos,
274                                               pageContext.getRequest().getCharacterEncoding())));
275
276          // 2004-01-13 HKK: Add support for childField/parentField
277
if ((getConfig()
278                        .getTableByName(destTable) != getTable())
279                    && (getParentForm()
280                                 .getTable() != null)) {
281             tagBuf.append(getDataTag(tagName, "srcTable",
282                                      getParentForm().getTable().getName()));
283             tagBuf.append(getDataTag(tagName, "childField",
284                                      Util.encode(childField,
285                                                  pageContext.getRequest().getCharacterEncoding())));
286             tagBuf.append(getDataTag(tagName, "parentField",
287                                      Util.encode(parentField,
288                                                  pageContext.getRequest().getCharacterEncoding())));
289          }
290
291          tagBuf.append(getDataTag(tagName, "singleRow", getSingleRow()));
292
293          tagBuf.append(getButtonBegin());
294          tagBuf.append(" name=\"");
295          tagBuf.append(tagName);
296          tagBuf.append(getButtonEnd());
297
298          pageContext.getOut()
299                     .write(tagBuf.toString());
300       } catch (java.io.IOException JavaDoc ioe) {
301          throw new JspException JavaDoc("IO Error: " + ioe.getMessage());
302       }
303
304       if (getChoosenFlavor() == FLAVOR_MODERN) {
305          return EVAL_BODY_BUFFERED;
306       } else {
307          return SKIP_BODY;
308       }
309    }
310 }
311
Popular Tags