问题
I am successfully opening new browser windows with BrowserWindowOpener.
Question: How do I pass some information to the newly instantiated UI subclass?
The syntax requires that I specify a class to be instantiated. How do I communicate with that future instance?
BrowserWindowOpener bookOpener = new BrowserWindowOpener( BookUI.class );
For example, let's say my app opens a window listing word definitions for words starting with a particular letter of the alphabet (A-Z). How do I tell the newly opening UI that it should show the "A" words, the "B" words, or the "V" words?
I noticed the BrowserWindowOpenerState class, but its use is not documented.
回答1:
I have not tried this, but a quick look at the javadoc suggests that by using BrowserWindowOpener#setParameter or BrowserWindowOpener#setUriFragment you can pass parameters into the UI.
E.g.
BrowserWindowOpener bookOpener = new BrowserWindowOpener( BookUI.class );
bookOpener.setParameter("startLetter", "A");
...
class BookUI {
protected abstract void init(VaadinRequest request){
String startLetter = request.getParameter("startLetter");
// Etc
}
}
来源:https://stackoverflow.com/questions/15938702/in-vaadin-7-pass-data-arguments-to-new-ui-instance-of-browserwindowopener