Directory

← Back

Enhanced Window Opener

Enhanced Window Opener

Author

Rating

Popularity

<100

Enhanced Window Opener is an extension of Vaadin BrowserWindowOpener that aims to simplify the opening of generated content in a new browser window or tab.

There are a lot of post on Vaadin forum regarding the usage BrowserWindowOpener extension. The main problems encountered by people depends on a misunderstanding of how BrowserWindowOpener works; it does not open a window immediately when the target component is extended but instead it adds a client side click listener on target component, so its effects are available only after the connector has done its work.

Usually problems comes from extending a component or setting the resource to open inside a server side listener (e.g. Button click listener)

Button button = new Button();
button.addClickListener( e -> {
    new BrowserWindowOpener(runtimeGeneratedResource())
        .extend(button);
});

This leeds to two problems:

  1. the window will not be opened after the click but only on the next click on the button
  2. the second click on the button will open the window but, after that, it will also execute the server side listener extending the button once again and consequently adding another click listener on the client side; next time clicking the button will open two windows and so on

The aim of this addon is to simplify opening window for runtime generated content and to avoid multiple window opening due to wrong usage of BrowserWindowOpener.

Button button = new Button("Click me");
new EnhancedBrowserWindowOpener()
    .clientSide(true)
    .withGeneratedContent("myFileName.txt", this::makeStreamSource)
    .doExtend(button);

See project page for further informations.

Sample code

Link link = new Link("Click me", null);
new EnhancedBrowserWindowOpener()
    .clientSide(true)
    .withGeneratedContent("myFileName.txt", this::makeStreamSource)
    .doExtend(link);
EnhancedBrowserWindowOpener opener = new EnhancedBrowserWindowOpener()
    .popupBlockerWorkaround(true);
Button button = new Button("Click me");
button.addClickListener(e -> {
    opener.open(generateResource());
});
opener.extend(button1);

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

Added support for shortcuts

Released
2018-07-16
Maturity
BETA
License
Apache License 2.0

Compatibility

Framework
Vaadin 7.6+
Vaadin 8.4+ in 0.4
Vaadin 8.3 in 0.3
Vaadin 8.2 in 0.3
Vaadin 8.1 in 0.3
Vaadin 8.0 in 0.3
Browser
N/A

Enhanced Window Opener - Vaadin Add-on Directory

Enhanced Window Opener Enhanced Window Opener - Vaadin Add-on Directory
Enhanced Window Opener is an extension of Vaadin BrowserWindowOpener that aims to simplify the opening of generated content in a new browser window or tab. There are a lot of post on Vaadin forum regarding the usage `BrowserWindowOpener` extension. The main problems encountered by people depends on a misunderstanding of how `BrowserWindowOpener` works; it does not open a window immediately when the target component is extended but instead it adds a client side click listener on target component, so its effects are available only after the connector has done its work. Usually problems comes from extending a component or setting the resource to open inside a server side listener (e.g. Button click listener) ```java Button button = new Button(); button.addClickListener( e -> { new BrowserWindowOpener(runtimeGeneratedResource()) .extend(button); }); ``` This leeds to two problems: 1. the window will not be opened after the click but only on the next click on the button 1. the second click on the button will open the window but, after that, it will also execute the server side listener extending the button once again and consequently adding another click listener on the client side; next time clicking the button will open two windows and so on The aim of this addon is to simplify opening window for runtime generated content and to avoid multiple window opening due to wrong usage of `BrowserWindowOpener`. ```java Button button = new Button("Click me"); new EnhancedBrowserWindowOpener() .clientSide(true) .withGeneratedContent("myFileName.txt", this::makeStreamSource) .doExtend(button); ``` See [project page](https://github.com/mcollovati/enhanced-window-opener) for further informations.
Online