View Javadoc

1   /*
2    * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/taglib/DbNavFirstButtonTag.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 "first"-button.
36   *
37   * @author Joachim Peer
38   */
39  public class DbNavFirstButtonTag extends AbstractDbBaseButtonTag
40     implements javax.servlet.jsp.tagext.TryCatchFinally {
41  
42     /***
43      * DOCUMENT ME!
44      */
45     public void doFinally() {
46        super.doFinally();
47     }
48  
49  
50     /***
51      * DOCUMENT ME!
52      *
53      * @return DOCUMENT ME!
54      *
55      * @throws javax.servlet.jsp.JspException DOCUMENT ME!
56      * @throws JspException DOCUMENT ME!
57      */
58     public int doStartTag() throws javax.servlet.jsp.JspException {
59        super.doStartTag();
60  
61        if (getParentForm()
62                     .isFooterReached()
63                  && ResultSetVector.isNull(getParentForm().getResultSetVector())) {
64           // 20030521 HKK: Bug fixing, thanks to Michael Slack! 
65           return SKIP_BODY;
66        }
67  
68        boolean isFirstPage = getParentForm()
69                                 .getResultSetVector()
70                                 .isFirstPage();
71  
72        try {
73           //20040227 JFM
74           if (isFirstPage && "nohtml".equals(getDisabledBehaviour())) {
75              return SKIP_BODY;
76           } else if (isFirstPage && "altimage".equals(getDisabledBehaviour())) {
77              pageContext.getOut()
78                         .write(getDisabledImage());
79  
80              return SKIP_BODY;
81           }
82           //default: "disabled".equals(getDisabledBehaviour())
83           else {
84              StringBuffer tagBuf  = new StringBuffer();
85              String       tagName = EventType.EVENT_NAVIGATION_TRANSFER_FIRST
86                                     + getTable()
87                                          .getId() + "_"
88                                     + Integer.toString(getUniqueID());
89  
90              if (getFollowUp() != null) {
91                 tagBuf.append(getDataTag(tagName, "fu", getFollowUp()));
92              }
93  
94              if (getFollowUpOnError() != null) {
95                 tagBuf.append(getDataTag(tagName, "fue", getFollowUpOnError()));
96              }
97  
98              tagBuf.append(getButtonBegin());
99  
100             if (isFirstPage) {
101                tagBuf.append(" disabled=\"true\"");
102             }
103 
104             tagBuf.append(" name=\"");
105             tagBuf.append(tagName);
106             tagBuf.append(getButtonEnd());
107 
108             pageContext.getOut()
109                        .write(tagBuf.toString());
110          }
111       } catch (java.io.IOException ioe) {
112          throw new JspException("IO Error: " + ioe.getMessage());
113       }
114 
115       if (getChoosenFlavor() == FLAVOR_MODERN) {
116          return EVAL_BODY_BUFFERED;
117       } else {
118          return SKIP_BODY;
119       }
120    }
121 }