BrowserWindowOpener inside buttonClick() causes problem


I am integrating my wep app from Vaadin 6 to Vaadin 7. I have a class that include

  • a table with checkbox column
  • a button that should do 2 things: (1) check which rows user has selected from the table and get some data from db based on selection. (2) after that, a new browser popup should be opened with fetched data.

The simplified source code of the above-mentioned functionality:

// create a table with one checkbox column
final Table table = new Table();
table.addContainerProperty("Select", CheckBox.class,  null);
for (int i=0; i<10; i++) {
   CheckBox selectable = new CheckBox("");
   table.addItem(new Object[] {selectable });

// create button
Button button = new Button("Create report");
button.addClickListener(new Button.ClickListener() {
   public void buttonClick(ClickEvent event) {

   // go through all table rows and check wich of them are selected
   while (---) {
      if (checkbox.getValue())
         // get some data from db and store it to Vaadin session

   // finally open new popup.
   BrowserWindowOpener popupOpener = new BrowserWindowOpener(Report.class);


// add button to layout

This implementation has one problem:

  • when I click the button first time nothing happens. No popup is opened.
  • however, when I click the button second time, a popup is opened. But I want that popup opens when clicking first time :slight_smile:

Is this a bug in vaadin 7.0? Or should I implement this in different way?

I’m having the same problem.
Seems that the first time the button is clicked, the popupOpener is extended to the component, so the first time the popupOpener will not “fire”.
Thats ugly for opening dynamic URLs (e.g. with a parameter/id from a table)

When you extend components, you don’t need to add any click listener, so try this way:

// create button
Button button = new Button("Create report");

// finally open new popup.
BrowserWindowOpener popupOpener = new BrowserWindowOpener(Report.class);

Let me know if it works,


The main thing is that I want to do two things with one button click:

(1) check wich rows user has selected in the table and fetch data based on the selection, and
(2) open new popup where data is shown

If I move BrowserWindowOpener outside from the buttonClick(), then popup is opened with one click, which is OK. But, then the code inside buttonClick() (1) is ignored - no rows are checked or data fetched.

I was wondering can this be done using Vaadin 7? Or am I missing something here…

Based on you post, I think what you are trying to do is to open up a pop up window according to Table selection. One way to do this is:

  1. You should move BrowserWindowOpener outside from the buttonClick()
  2. Pass the Table selection (id or sth else) with the setParameter method of BrowserWindowOpener, and obviously you should do this in the Button’s clickListener.
  3. Get the Data according to the selection (parameter in the url) in the Report UI’s init method

This should solve your problem, but let me know if this doesn’t work.

You can check
Opening a UI in a popup window
to see how to use setParameter and how to use the parameter in the Popup UI.

Hmm, I don’t think that this will work, because the BrowserWindowOpener acts before the Cllicklistener Event has occurd (respectively in another thread).
Have you already tried it out?

Yes, I’ve tried, it works.
You set the parameter in the clickListener, the parameter in the url of the popup window is changed. Then in the init method of the popup UI, you can do whatever you need to do with those parameters.

Why don’t you just have a simple test?

Thanks for replies.

In my case the problem with setParameter -merhod is that it allows only to set String type parameters. I need to give a various types of parameters such as Date and custom Object types.

I tried tu put the parameters into VaadinSession and fetch them in popup init method. This works with Firefox, but does not work correclt with Interner Exloperer.

Actually my issue is that Internet Explorer acts in different way than Firefox or Chrome (which is not surprising).

My code:

	    final Button forCustomerUse = new Button("Customer Report");
            BrowserWindowOpener popupOpener = new BrowserWindowOpener(CustomerViewersDetailedView.class);
	    forCustomerUse.addClickListener(new Button.ClickListener() {
	            public void buttonClick(ClickEvent event) {
                      // do stuff

Firefox and Chrome first handle code inside method buttonClick(ClickEvent event), and after that opens new popup.

However, Internet Explorer first opens new popup, and after that handles code inside method buttonClick(ClickEvent event). This causes null pointer exception when opening popup as the displayed data on fetched from db inside buttonClick(ClickEvent event) and stored into VaadinSession.

So, is there any workaround for Internet Explorer case? :slight_smile:

Hi Sami, thank you for informing this IE problem (I didn’t try with IE), if it is the case, I think you can help to create a ticket for that.

Here is what I though maybe a workaround: The UI can find each other with
, methods available are “getUIbyId” and “getUIs”, so in the main UI, you can get the CustomerViewersDetailedView UI, then updates the CustomerViewersDetailedView UI in the server side, in the end use the Vaadin
ICEPush Addon
to push the changes to browser.

You can have a try, hopefully this will be helpful.

Ok, thanks for help.

Ticket #11110: Vaadin 7: buttonClick + BrowserWindowOpener does not work correctly in IE created for this purpose.


I’ve tried everything but it does not work.
Here is my code snippet.

public class TestUI extends UI {

	Button button = new Button("Click Me");
	BrowserWindowOpener bwo = new BrowserWindowOpener("");

	protected void init(VaadinRequest request) {


		button.addClickListener(new Button.ClickListener() {
			public void buttonClick(ClickEvent event) {
				bwo.setParameter("saddr", "Germany");

		VerticalLayout layout = new VerticalLayout();


Only after the second click the map of Germany is displayed.

BrowserWindowOpener acts before onClick handler. Move your code to onClick and use getUI().getPage().open(url) to open a browser window after button click.


1)Define BrowserWindowOpener globally as :
BrowserWindowOpener opener = new BrowserWindowOpener(Report.class);
2)Button submitQuery = new Button(“Submit”);
submitQuery.addClickListener(new Button.ClickListener() {
public void buttonClick(com.vaadin.ui.Button.ClickEvent event) {
—do whatever you want —

Hi , this post really helped me. I was facing the same issue and now it works. But, the only bad thing is that the first time a click the button it opens a blank tab, no url. All the other times I click the button I get the properly changed url and the tab opens with the new url.
I am using this solution to open new tabs with audio files which I need the browser to start playing them on click.