Open the download window by clicking MenuItem
2 answers
Maybe a little javascript can help you:
Upload upload = new Upload();
upload.setImmediate(true); // if you want to start upload after selection
upload.addStyleName("my-upload");
MenuBar menuBar = new MenuBar();
menuBar.addItem("Caption", new Command() {
private static final long serialVersionUID = 1L;
@Override
public void menuSelected(MenuItem selectedItem) {
JavaScript.getCurrent().execute(
"document.getElementsByClassName('gwt-FileUpload')[0].click()");
}
});
addComponent(upload);
addComponent(menuBar);
If you want to hide the download:
.v-slot-my-upload {
display: none;
}
+2
source to share
The simplest utility MenuBar, MenuItem, Window and Upload, the layout is left for you:
MenuBar menuBar = new MenuBar();
final Window window = new Window();
window.setContent(new Upload());
menuBar.addItem("Caption", new Command()
{
@Override
public void menuSelected(MenuItem selectedItem)
{
UI.getCurrent().addWindow(window);
}
});
+1
source to share