blob: 6392d5c7ff6776085a7d284e0d8b3fe2e842b85f (
plain)
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
|
package com.vaadin.tests.components.upload;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Button;
import com.vaadin.ui.Upload;
import com.vaadin.ui.Upload.Receiver;
import com.vaadin.v7.ui.TextField;
public class ForceSubmit extends TestBase implements Receiver {
@Override
protected Integer getTicketNumber() {
return 6630;
}
@Override
public OutputStream receiveUpload(String filename, String MIMEType) {
return new ByteArrayOutputStream();
}
@Override
protected void setup() {
final TextField textField = new TextField("Test field");
addComponent(textField);
final Upload u;
u = new Upload("Upload", this);
u.setButtonCaption(null);
addComponent(u);
u.addFinishedListener(event -> {
String filename = event.getFilename();
long length = event.getLength();
getMainWindow().showNotification(
"Done. Filename : " + filename + " Lenght: " + length);
});
u.addFailedListener(event -> getMainWindow()
.showNotification("Failed. No file selected?"));
u.addStartedListener(event -> getMainWindow().showNotification(
"Started upload. TF value :" + textField.getValue()));
Button button = new Button(
"I'm an external button (not the uploads builtin), hit me to start upload.");
button.addClickListener(event -> u.submitUpload());
addComponent(button);
}
@Override
protected String getDescription() {
return "Some wireframists are just so web 1.0. If requirements "
+ "say the upload must not start until the whole form "
+ "is 'Oukeyd', that is what we gotta do. In these cases "
+ "developers most probably also want to hide the uploads"
+ " internal button by setting its caption to null.";
}
}
|