-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathUploadButton.java
More file actions
69 lines (59 loc) · 1.69 KB
/
Copy pathUploadButton.java
File metadata and controls
69 lines (59 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package javaforce.webui;
import javaforce.webui.tasks.*;
/** Upload Button
*
* @author pquiring
*/
public class UploadButton extends Button {
public UploadButton(String text) {
super(text);
}
public UploadButton(Resource img) {
super(img);
}
public UploadButton(Icon icon) {
super(icon);
}
public UploadButton(Resource img, String text) {
super(img, text);
}
public UploadButton(Icon icon, String text) {
super(icon, text);
}
public void init() {
super.init();
setClass("upload");
}
public String getUploadFolder() {
return client.getUploadFolder();
}
public void setUploadFolder(String folder) {
client.setUploadFolder(folder);
}
public Status getUploadStatus() {
return client.getUploadStatus();
}
public void setUploadStatus(Status status) {
client.setUploadStatus(status);
}
public String html() {
StringBuilder html = new StringBuilder();
html.append("<form method='post' id='f" + id + "' enctype='multipart/form-data' target='upload'>");
html.append("<input type='hidden' id='s" + id + "' name='size'>");
html.append("<input type='hidden' name='client' id='c" + id + "' value='" + client.hash + "'>");
html.append("<input type='file' name='file' id='i" + id + "' style='display: none;' onchange=\"onchangeUpload(event, this, '" + id + "');\">"); //'multiple' not supported yet
html.append("<label for='i" + id + "'" + getAttrs() + ">");
if (img != null) {
html.append(img.html());
}
if (icon != null) {
html.append(icon.html());
}
if (text != null) {
html.append(text);
}
html.append("</label>");
html.append("</form>");
return html.toString();
}
}