KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/taglib/DbNavPrevButtonTag.java,v 1.23 2004/10/20 10:52:02 hkollmann Exp $
3  * $Revision: 1.23 $
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 javax.servlet.jsp.JspException JavaDoc;
31
32
33
34 /**
35  * this tag renders an "previous"-button.
36  *
37  * @author Joachim Peer
38  */

39 public class DbNavPrevButtonTag extends DbBaseButtonTag
40    implements javax.servlet.jsp.tagext.TryCatchFinally JavaDoc {
41    private String JavaDoc stepWidth;
42
43    /**
44     * DOCUMENT ME!
45     *
46     * @param stepWidth DOCUMENT ME!
47     */

48    public void setStepWidth(String JavaDoc stepWidth) {
49       this.stepWidth = stepWidth;
50    }
51
52
53    /**
54     * DOCUMENT ME!
55     *
56     * @return DOCUMENT ME!
57     */

58    public String JavaDoc getStepWidth() {
59       return stepWidth;
60    }
61
62
63    /**
64     * @see javax.servlet.jsp.tagext.TryCatchFinally#doCatch(java.lang.Throwable)
65     */

66    public void doCatch(Throwable JavaDoc t) throws Throwable JavaDoc {
67       throw t;
68    }
69
70
71    /**
72     * DOCUMENT ME!
73     */

74    public void doFinally() {
75       stepWidth = null;
76       super.doFinally();
77    }
78
79
80    /**
81     * DOCUMENT ME!
82     *
83     * @return DOCUMENT ME!
84     *
85     * @throws javax.servlet.jsp.JspException DOCUMENT ME!
86     * @throws JspException DOCUMENT ME!
87     */

88    public int doStartTag() throws javax.servlet.jsp.JspException JavaDoc {
89       super.doStartTag();
90
91       if (getParentForm()
92                    .isFooterReached()
93                 && ResultSetVector.isNull(getParentForm().getResultSetVector())) {
94          // 20030521 HKK: Bug fixing, thanks to Michael Slack!
95
return SKIP_BODY;
96       }
97
98       boolean isFirstPage = getParentForm()
99                                .getResultSetVector()
100                                .isFirstPage();
101
102       try {
103          //20040225 JFM
104
if (isFirstPage && "nohtml".equals(getDisabledBehaviour())) {
105             return SKIP_BODY;
106          } else if (isFirstPage && "altimage".equals(getDisabledBehaviour())) {
107             pageContext.getOut()
108                        .write(getDisabledImage());
109
110             return SKIP_BODY;
111          }
112          //default: "disabled".equals(getDisabledBehaviour())
113
else {
114             StringBuffer JavaDoc tagBuf = new StringBuffer JavaDoc();
115             String JavaDoc tagName = EventType.EVENT_NAVIGATION_TRANSFER_PREV
116                                    + getTable()
117                                         .getId() + "_"
118                                    + Integer.toString(getUniqueID());
119
120             if (stepWidth != null) {
121                tagBuf.append(getDataTag(tagName, "sw", stepWidth));
122             }
123
124             if (getFollowUp() != null) {
125                tagBuf.append(getDataTag(tagName, "fu", getFollowUp()));
126             }
127
128             if (getFollowUpOnError() != null) {
129                tagBuf.append(getDataTag(tagName, "fue", getFollowUpOnError()));
130             }
131
132             tagBuf.append(getButtonBegin());
133
134             if (isFirstPage) {
135                tagBuf.append(" disabled=\"true\"");
136             }
137
138             tagBuf.append(" name=\"");
139             tagBuf.append(tagName);
140             tagBuf.append(getButtonEnd());
141
142             pageContext.getOut()
143                        .write(tagBuf.toString());
144          }
145       } catch (java.io.IOException JavaDoc ioe) {
146          throw new JspException JavaDoc("IO Error: " + ioe.getMessage());
147       }
148
149       if (getChoosenFlavor() == FLAVOR_MODERN) {
150          return EVAL_BODY_BUFFERED;
151       } else {
152          return SKIP_BODY;
153       }
154    }
155 }
156
Popular Tags