View Javadoc

1   /*
2    * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/taglib/DbNavPrevButtonTag.java,v 1.25 2006/01/13 13:38:51 hkollmann Exp $
3    * $Revision: 1.25 $
4    * $Date: 2006/01/13 13:38:51 $
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;
31  
32  
33  
34  /***
35   * this tag renders an "previous"-button.
36   *
37   * @author Joachim Peer
38   */
39  public class DbNavPrevButtonTag extends AbstractDbBaseButtonTag
40     implements javax.servlet.jsp.tagext.TryCatchFinally {
41     private String stepWidth;
42  
43     /***
44      * DOCUMENT ME!
45      *
46      * @param stepWidth DOCUMENT ME!
47      */
48     public void setStepWidth(String stepWidth) {
49        this.stepWidth = stepWidth;
50     }
51  
52  
53     /***
54      * DOCUMENT ME!
55      *
56      * @return DOCUMENT ME!
57      */
58     public String getStepWidth() {
59        return stepWidth;
60     }
61  
62     /***
63      * DOCUMENT ME!
64      */
65     public void doFinally() {
66        stepWidth = null;
67        super.doFinally();
68     }
69  
70  
71     /***
72      * DOCUMENT ME!
73      *
74      * @return DOCUMENT ME!
75      *
76      * @throws javax.servlet.jsp.JspException DOCUMENT ME!
77      * @throws JspException DOCUMENT ME!
78      */
79     public int doStartTag() throws javax.servlet.jsp.JspException {
80        super.doStartTag();
81  
82        if (getParentForm()
83                     .isFooterReached()
84                  && ResultSetVector.isNull(getParentForm().getResultSetVector())) {
85           // 20030521 HKK: Bug fixing, thanks to Michael Slack! 
86           return SKIP_BODY;
87        }
88  
89        boolean isFirstPage = getParentForm()
90                                 .getResultSetVector()
91                                 .isFirstPage();
92  
93        try {
94           //20040225 JFM
95           if (isFirstPage && "nohtml".equals(getDisabledBehaviour())) {
96              return SKIP_BODY;
97           } else if (isFirstPage && "altimage".equals(getDisabledBehaviour())) {
98              pageContext.getOut()
99                         .write(getDisabledImage());
100 
101             return SKIP_BODY;
102          }
103          //default: "disabled".equals(getDisabledBehaviour())
104          else {
105             StringBuffer tagBuf  = new StringBuffer();
106             String       tagName = EventType.EVENT_NAVIGATION_TRANSFER_PREV
107                                    + getTable()
108                                         .getId() + "_"
109                                    + Integer.toString(getUniqueID());
110 
111             if (stepWidth != null) {
112                tagBuf.append(getDataTag(tagName, "sw", stepWidth));
113             }
114 
115             if (getFollowUp() != null) {
116                tagBuf.append(getDataTag(tagName, "fu", getFollowUp()));
117             }
118 
119             if (getFollowUpOnError() != null) {
120                tagBuf.append(getDataTag(tagName, "fue", getFollowUpOnError()));
121             }
122 
123             tagBuf.append(getButtonBegin());
124 
125             if (isFirstPage) {
126                tagBuf.append(" disabled=\"true\"");
127             }
128 
129             tagBuf.append(" name=\"");
130             tagBuf.append(tagName);
131             tagBuf.append(getButtonEnd());
132 
133             pageContext.getOut()
134                        .write(tagBuf.toString());
135          }
136       } catch (java.io.IOException ioe) {
137          throw new JspException("IO Error: " + ioe.getMessage());
138       }
139 
140       if (getChoosenFlavor() == FLAVOR_MODERN) {
141          return EVAL_BODY_BUFFERED;
142       } else {
143          return SKIP_BODY;
144       }
145    }
146 }