KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/taglib/DbFileTag.java,v 1.18 2004/08/18 12:26:06 hkollmann Exp $
3  * $Revision: 1.18 $
4  * $Date: 2004/08/18 12:26:06 $
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.apache.commons.logging.Log;
27 import org.apache.commons.logging.LogFactory;
28
29 import javax.servlet.jsp.*;
30
31
32
33 /**
34  * <p>
35  * This tag renders a HTML TextArea - Element
36  * </p>
37  * this tag renders a dabase-datadriven textArea, which is an active element -
38  * the user can change data
39  *
40  * @author Joachim Peer
41  */

42 public class DbFileTag extends DbBaseInputTag
43    implements javax.servlet.jsp.tagext.TryCatchFinally JavaDoc {
44    private static Log logCat = LogFactory.getLog(DbFileTag.class.getName());
45    private String JavaDoc accept;
46
47    /**
48     * DOCUMENT ME!
49     *
50     * @param accept DOCUMENT ME!
51     */

52    public void setAccept(String JavaDoc accept) {
53       this.accept = accept;
54    }
55
56
57    /**
58     * DOCUMENT ME!
59     *
60     * @return DOCUMENT ME!
61     */

62    public String JavaDoc getAccept() {
63       return accept;
64    }
65
66
67    /**
68     * @see javax.servlet.jsp.tagext.TryCatchFinally#doCatch(java.lang.Throwable)
69     */

70    public void doCatch(Throwable JavaDoc t) throws Throwable JavaDoc {
71       throw t;
72    }
73
74
75    /**
76     * DOCUMENT ME!
77     *
78     * @return DOCUMENT ME!
79     *
80     * @throws javax.servlet.jsp.JspException DOCUMENT ME!
81     * @throws JspException DOCUMENT ME!
82     */

83    public int doEndTag() throws javax.servlet.jsp.JspException JavaDoc {
84       try {
85          StringBuffer JavaDoc tagBuf = new StringBuffer JavaDoc();
86
87          if (hasReadOnlySet() || getParentForm()
88                                           .hasReadOnlySet()) {
89             // if read-only, remove the browse button (for netscape problem)
90
tagBuf.append("<input type=\"text\"");
91          } else {
92             tagBuf.append("<input type=\"file\"");
93          }
94
95          tagBuf.append(prepareName());
96
97          if (accept != null) {
98             tagBuf.append(" accept=\"");
99             tagBuf.append(accept);
100             tagBuf.append("\"");
101          }
102
103          tagBuf.append(prepareSize());
104          tagBuf.append(prepareKeys());
105          tagBuf.append(prepareStyles());
106          tagBuf.append(prepareEventHandlers());
107          tagBuf.append("/>");
108
109          // Writes out the old field value
110
// Joe Peer: this is deadly for FileTags
111
//writeOutSpecialValues();
112
pageContext.getOut()
113                     .write(tagBuf.toString());
114       } catch (java.io.IOException JavaDoc ioe) {
115          throw new JspException("IO Error: " + ioe.getMessage());
116       }
117
118       return EVAL_PAGE;
119    }
120
121
122    /**
123     * DOCUMENT ME!
124     */

125    public void doFinally() {
126       accept = null;
127       super.doFinally();
128    }
129
130
131    /**
132     * DOCUMENT ME!
133     *
134     * @return DOCUMENT ME!
135     *
136     * @throws javax.servlet.jsp.JspException DOCUMENT ME!
137     * @throws JspException DOCUMENT ME!
138     */

139    public int doStartTag() throws javax.servlet.jsp.JspException JavaDoc {
140       super.doStartTag();
141
142       if (!getParentForm()
143                     .hasMultipartSet()) {
144          logCat.warn("DbFileTag is used but DbFormTag.multipart is not set (FALSE)");
145          throw new JspException("DbFileTag is used but DbFormTag.multipart is not set (it is set to \"FALSE\"). you must set it to \"TRUE\" to enable file uploads!");
146       }
147
148       return SKIP_BODY;
149    }
150 }
151
Popular Tags