View Javadoc

1   /*
2    * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/taglib/DbNavNextButtonTag.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 a "next"-button.
36   *
37   * @author Joachim Peer
38   */
39  public class DbNavNextButtonTag 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     /***
64      * DOCUMENT ME!
65      */
66     public void doFinally() {
67        stepWidth = null;
68        super.doFinally();
69     }
70  
71  
72     /***
73      * DOCUMENT ME!
74      *
75      * @return DOCUMENT ME!
76      *
77      * @throws javax.servlet.jsp.JspException DOCUMENT ME!
78      * @throws JspException DOCUMENT ME!
79      */
80     public int doStartTag() throws javax.servlet.jsp.JspException {
81        super.doStartTag();
82  
83        if (getParentForm()
84                     .isFooterReached()
85                  && ResultSetVector.isNull(getParentForm().getResultSetVector())) {
86           // 20030521 HKK: Bug fixing, thanks to Michael Slack! 
87           return SKIP_BODY;
88        }
89  
90        boolean isLastPage = getParentForm()
91                                .getResultSetVector()
92                                .isLastPage();
93  
94        try {
95           //20040227 JFM
96           if (isLastPage && "nohtml".equals(getDisabledBehaviour())) {
97              return SKIP_BODY;
98           } else if (isLastPage && "altimage".equals(getDisabledBehaviour())) {
99              pageContext.getOut()
100                        .write(getDisabledImage());
101 
102             return SKIP_BODY;
103          }
104          //default: "disabled".equals(getDisabledBehaviour())
105          else {
106             StringBuffer tagBuf  = new StringBuffer();
107             String       tagName = EventType.EVENT_NAVIGATION_TRANSFER_NEXT
108                                    + getTable()
109                                         .getId() + "_"
110                                    + Integer.toString(getUniqueID());
111 
112             if (stepWidth != null) {
113                tagBuf.append(getDataTag(tagName, "sw", stepWidth));
114             }
115 
116             if (getFollowUp() != null) {
117                tagBuf.append(getDataTag(tagName, "fu", getFollowUp()));
118             }
119 
120             if (getFollowUpOnError() != null) {
121                tagBuf.append(getDataTag(tagName, "fue", getFollowUpOnError()));
122             }
123 
124             tagBuf.append(getButtonBegin());
125 
126             if (isLastPage) {
127                tagBuf.append(" disabled=\"true\"");
128             }
129 
130             tagBuf.append(" name=\"");
131             tagBuf.append(tagName);
132             tagBuf.append(getButtonEnd());
133 
134             pageContext.getOut()
135                        .write(tagBuf.toString());
136          }
137       } catch (java.io.IOException ioe) {
138          throw new JspException("IO Error: " + ioe.getMessage());
139       }
140 
141       if (getChoosenFlavor() == FLAVOR_MODERN) {
142          return EVAL_BODY_BUFFERED;
143       } else {
144          return SKIP_BODY;
145       }
146    }
147 }