View Javadoc

1   /*
2    * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/taglib/DbNavCopyButtonTag.java,v 1.17 2006/01/13 13:38:51 hkollmann Exp $
3    * $Revision: 1.17 $
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 org.dbforms.util.Util;
31  
32  import javax.servlet.jsp.JspException;
33  
34  
35  
36  /***
37   * this tag renders an "copy"-button.
38   *
39   * @author Stefano Borghi
40   * @version $Revision: 1.17 $
41   */
42  public class DbNavCopyButtonTag extends AbstractDbBaseButtonTag
43     implements javax.servlet.jsp.tagext.TryCatchFinally {
44     /*** Holds value of property showAlwaysInFooter. */
45     private String showAlwaysInFooter = "true";
46  
47     /***
48      * DOCUMENT ME!
49      *
50      * @param string
51      */
52     public void setShowAlwaysInFooter(String string) {
53        showAlwaysInFooter = string;
54     }
55  
56  
57     /***
58      * DOCUMENT ME!
59      *
60      * @return
61      */
62     public String getShowAlwaysInFooter() {
63        return showAlwaysInFooter;
64     }
65  
66  
67     /***
68      * DOCUMENT ME!
69      */
70     public void doFinally() {
71        showAlwaysInFooter = "true";
72        super.doFinally();
73     }
74  
75  
76     /***
77      * DOCUMENT ME!
78      *
79      * @return DOCUMENT ME!
80      *
81      * @throws javax.servlet.jsp.JspException DOCUMENT ME!
82      * @throws JspException DOCUMENT ME!
83      */
84     public int doStartTag() throws javax.servlet.jsp.JspException {
85        super.doStartTag();
86  
87        if (getParentForm()
88                     .isFooterReached()
89                  && ResultSetVector.isNull(getParentForm().getResultSetVector())
90                  && !Util.getTrue(showAlwaysInFooter)) {
91           // 20030521 HKK: Bug fixing, thanks to Michael Slack! 
92           return SKIP_BODY;
93        }
94  
95        try {
96           StringBuffer tagBuf  = new StringBuffer();
97           String       tagName = EventType.EVENT_NAVIGATION_TRANSFER_COPY
98                                  + getTable()
99                                       .getId() + "_"
100                                 + Integer.toString(getUniqueID());
101 
102          if (getFollowUp() != null) {
103             tagBuf.append(getDataTag(tagName, "fu", getFollowUp()));
104          }
105 
106          if (getFollowUpOnError() != null) {
107             tagBuf.append(getDataTag(tagName, "fue", getFollowUpOnError()));
108          }
109 
110          tagBuf.append(getButtonBegin());
111          tagBuf.append(" name=\"");
112          tagBuf.append(tagName);
113          tagBuf.append(getButtonEnd());
114 
115          pageContext.getOut()
116                     .write(tagBuf.toString());
117       } catch (java.io.IOException ioe) {
118          throw new JspException("IO Error: " + ioe.getMessage());
119       }
120 
121       if (getChoosenFlavor() == FLAVOR_MODERN) {
122          return EVAL_BODY_BUFFERED;
123       } else {
124          return SKIP_BODY;
125       }
126    }
127 }