Open the download window by clicking MenuItem
I want to open uploadwindow item from Upload by clicking MenuItem. Is it possible? Another idea is to add an upload element to the MenuBar, but I think this is not possible, right?
Thanks for the help!
+3
Sheldon
source
to share
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
Krayo
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
Zigac
source
to share