KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/taglib/DbUpdateButtonTag.java,v 1.26 2004/10/20 10:52:03 hkollmann Exp $
3  * $Revision: 1.26 $
4  * $Date: 2004/10/20 10:52:03 $
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.util.Util;
29
30 import org.dbforms.validation.ValidatorConstants;
31
32 import javax.servlet.jsp.JspException JavaDoc;
33
34
35
36 /**
37  * <p>
38  * this tag renders an update-button. #fixme - define abstract base class
39  * [should be fixed in release 0.6]
40  * </p>
41  *
42  * @author Joachim Peer
43  */

44 public class DbUpdateButtonTag extends DbBaseButtonTag
45    implements javax.servlet.jsp.tagext.TryCatchFinally JavaDoc {
46    private String JavaDoc associatedRadio;
47    private String JavaDoc showAlways = "false";
48
49    /**
50     * DOCUMENT ME!
51     *
52     * @param associatedRadio DOCUMENT ME!
53     */

54    public void setAssociatedRadio(String JavaDoc associatedRadio) {
55       this.associatedRadio = associatedRadio;
56    }
57
58
59    /**
60     * DOCUMENT ME!
61     *
62     * @return DOCUMENT ME!
63     */

64    public String JavaDoc getAssociatedRadio() {
65       return associatedRadio;
66    }
67
68
69    /**
70     * DOCUMENT ME!
71     *
72     * @param string
73     */

74    public void setShowAlways(String JavaDoc string) {
75       showAlways = string;
76    }
77
78
79    /**
80     * DOCUMENT ME!
81     *
82     * @return
83     */

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

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

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

115    public int doStartTag() throws javax.servlet.jsp.JspException JavaDoc {
116       super.doStartTag();
117
118       if (!Util.getTrue(showAlways)
119                 && getParentForm()
120                             .isFooterReached()
121                 && ResultSetVector.isNull(getParentForm().getResultSetVector())) {
122          // 20030521 HKK: Bug fixing, thanks to Michael Slack!
123
return SKIP_BODY;
124       }
125
126       try {
127          // first, determinate the name of the button tag
128
StringBuffer JavaDoc tagNameBuf = new StringBuffer JavaDoc("ac_update");
129
130          if (associatedRadio != null) {
131             tagNameBuf.append("ar");
132          }
133
134          tagNameBuf.append("_");
135          tagNameBuf.append(getTable().getId());
136
137          if (associatedRadio == null) {
138             tagNameBuf.append("_");
139             tagNameBuf.append(getParentForm().getPositionPath());
140          }
141
142          // PG - Render the name unique
143
tagNameBuf.append("_");
144          tagNameBuf.append(Integer.toString(getUniqueID()));
145
146          String JavaDoc tagName = tagNameBuf.toString();
147
148          // then render it and its associtated data-tags
149
StringBuffer JavaDoc tagBuf = new StringBuffer JavaDoc();
150
151          if (associatedRadio != null) {
152             tagBuf.append(getDataTag(tagName, "arname", associatedRadio));
153          }
154
155          if (getFollowUp() != null) {
156             tagBuf.append(getDataTag(tagName, "fu", getFollowUp()));
157          }
158
159          if (getFollowUpOnError() != null) {
160             tagBuf.append(getDataTag(tagName, "fue", getFollowUpOnError()));
161          }
162
163          tagBuf.append(getButtonBegin());
164          tagBuf.append(" name=\"");
165          tagBuf.append(tagName);
166          tagBuf.append(getButtonEnd());
167
168          pageContext.getOut()
169                     .write(tagBuf.toString());
170       } catch (java.io.IOException JavaDoc ioe) {
171          throw new JspException JavaDoc("IO Error: " + ioe.getMessage());
172       }
173
174       if (getChoosenFlavor() == FLAVOR_MODERN) {
175          return EVAL_BODY_BUFFERED;
176       } else {
177          return SKIP_BODY;
178       }
179    }
180
181
182    /**
183     * returns the JavaScript validation flags. Will be put into the onClick
184     * event of the main form Must be overloaded by update and delete button
185     *
186     * @return the java script validation vars.
187     */

188    protected String JavaDoc JsValidation() {
189       return (ValidatorConstants.JS_CANCEL_VALIDATION + "=true;"
190              + ValidatorConstants.JS_UPDATE_VALIDATION_MODE + "=true;");
191    }
192 }
193
Popular Tags