In Vaadin 7, pass data/arguments to new UI instance of BrowserWindowOpener?

可紊 提交于 2019-12-01 21:31:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!