I'm trying to use the Upload component to browse and upload a file i. What I want is only upload-functionality, but not the upload button and the browse button.I want to add a button to the page when a user click it the browse file window is opened so he can choose a file and upload it I wrote this :
@Override
protected void init(VaadinRequest request) {
final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
setContent(layout);
final Upload sample = new Upload(null, null);
Button button = new Button("Click Me");
sample.setImmediate(true);
sample.setButtonCaption(null);
System.out.println(sample.isVisible());
button.addClickListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
layout.addComponent(new Label("Thank you for clicking"));
sample.setVisible(true);
layout.addComponent(sample);
}
});
layout.addComponent(button);
}
}