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.addListener(new Upload.FinishedListener() {
@Override
public void uploadFinished(FinishedEvent event) {
String filename = event.getFilename();
long length = event.getLength();
getMainWindow().showNotification(
"Done. Filename : " + filename + " Lenght: " + length);
}
});
u.addListener(new Upload.FailedListener() {
@Override
public void uploadFailed(FailedEvent event) {
getMainWindow().showNotification("Failed. No file selected?");
}
});
u.addListener(new Upload.StartedListener() {
@Override
public void uploadStarted(StartedEvent 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.addListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
u.submitUpload();
}
});
addComponent(button);