4

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.

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
  • One workaround I found is to (1) Add member fields to my UI subclass, (2) Create a further subclass that hard-codes values into those member fields. In example above, this would mean creating 26 subclasses: "BookUI_A", "BookUI_B", "BookUI_C", and so on. Less than elegant. – Basil Bourque Apr 11 '13 at 21:33

1 Answers1

4

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
  }
} 
Charles Anthony
  • 3,155
  • 17
  • 21