You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

OpeningAUIInAPopupWindow.asciidoc 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. ---
  2. title: Opening A UI In A Popup Window
  3. order: 79
  4. layout: page
  5. ---
  6. [[opening-a-ui-in-a-popup-window]]
  7. Opening a UI in a popup window
  8. ------------------------------
  9. To open a new popup window in the browser showing another part of your
  10. application, you can use the new `BrowserWindowOpener` extension. Any
  11. component that you extend with `BrowserWindowOpener` will make clicking
  12. the component open a new browser window with some options for the
  13. content. Opening a popup this way helps you bypass most popup blockers.
  14. One of the things that `BrowserWindowOpener` can be configured to open
  15. in the new window is a new instance of a Vaadin UI class.
  16. [source,java]
  17. ....
  18. public class OpeningUIInPopup extends UI {
  19. @Override
  20. protected void init(VaadinRequest request) {
  21. Button popupButton = new Button("Open popup with MyPopupUI");
  22. BrowserWindowOpener popupOpener = new BrowserWindowOpener(MyPopupUI.class);
  23. popupOpener.setFeatures("height=300,width=300");
  24. popupOpener.extend(popupButton);
  25. // Add a parameter
  26. popupOpener.setParameter("foo", "bar");
  27. // Set a fragment
  28. popupOpener.setUriFragment("myfragment");
  29. setContent(popupButton);
  30. }
  31. }
  32. public class MyPopupUI extends UI {
  33. @Override
  34. protected void init(VaadinRequest request) {
  35. setContent(new Label("This is MyPopupUI where parameter foo="
  36. + request.getParameter("foo") + " and fragment is set to "
  37. + getPage().getUriFragment()));
  38. }
  39. }
  40. ....
  41. In this example, a `Button` is created and extended with a
  42. `BrowserWindowOpener`. Furthermore, the size of the popup window is
  43. defined. See
  44. https://developer.mozilla.org/en-US/docs/DOM/window.open#Position_and_size_features
  45. for a description of the commonly supported features. If you don't
  46. define any features, the browser will use its default setting which
  47. usually makes it open a new tab instead of opening a popup window.
  48. The `BrowserWindowOpener` can also be used to open a `Resource` or any
  49. URL that you define using different constructors.