1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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 AbstractDbBaseInputTag
43 implements javax.servlet.jsp.tagext.TryCatchFinally {
44 private static Log logCat = LogFactory.getLog(DbFileTag.class.getName());
45 private String accept;
46
47 /***
48 * DOCUMENT ME!
49 *
50 * @param accept DOCUMENT ME!
51 */
52 public void setAccept(String accept) {
53 this.accept = accept;
54 }
55
56
57 /***
58 * DOCUMENT ME!
59 *
60 * @return DOCUMENT ME!
61 */
62 public String getAccept() {
63 return accept;
64 }
65
66
67 /***
68 * DOCUMENT ME!
69 *
70 * @return DOCUMENT ME!
71 *
72 * @throws javax.servlet.jsp.JspException DOCUMENT ME!
73 * @throws JspException DOCUMENT ME!
74 */
75 public int doEndTag() throws javax.servlet.jsp.JspException {
76 try {
77 StringBuffer tagBuf = new StringBuffer();
78
79 if (hasReadOnlySet() || getParentForm()
80 .hasReadOnlySet()) {
81
82 tagBuf.append("<input type=\"text\"");
83 } else {
84 tagBuf.append("<input type=\"file\"");
85 }
86
87 tagBuf.append(prepareName());
88
89 if (accept != null) {
90 tagBuf.append(" accept=\"");
91 tagBuf.append(accept);
92 tagBuf.append("\"");
93 }
94
95 tagBuf.append(prepareSize());
96 tagBuf.append(prepareKeys());
97 tagBuf.append(prepareStyles());
98 tagBuf.append(prepareEventHandlers());
99 tagBuf.append("/>");
100
101
102
103
104 pageContext.getOut()
105 .write(tagBuf.toString());
106 } catch (java.io.IOException ioe) {
107 throw new JspException("IO Error: " + ioe.getMessage());
108 }
109
110 return EVAL_PAGE;
111 }
112
113
114 /***
115 * DOCUMENT ME!
116 */
117 public void doFinally() {
118 accept = null;
119 super.doFinally();
120 }
121
122
123 /***
124 * DOCUMENT ME!
125 *
126 * @return DOCUMENT ME!
127 *
128 * @throws javax.servlet.jsp.JspException DOCUMENT ME!
129 * @throws JspException DOCUMENT ME!
130 */
131 public int doStartTag() throws javax.servlet.jsp.JspException {
132 super.doStartTag();
133
134 if (!getParentForm()
135 .hasMultipartSet()) {
136 logCat.warn("DbFileTag is used but DbFormTag.multipart is not set (FALSE)");
137 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!");
138 }
139
140 return SKIP_BODY;
141 }
142 }