Multi-Window Application and best practices

Here is the problem. For a specific Vaadin application (which is a migration from an original multi-windowed swing application),
we want to have two separate window on a dual-screen display (a vaadin “window” per application).

The window on the left screen is the main window and is the place where most interactions will happen,
the window on the right screen is the secondary window and reacts to events happening on the main window (to display some more details for instance).



Question n°1:


What is the best practice in a Vaadin based application to support “multi-windowed” applications.



Question n°2:


If we use “Application-Level Windows”, [b]
[u]

[/u]how feasible is-it to position the second window directly on the “secondary display” ?
[/b]

  • this seems to be “not possible”, but is it truly impossible ? maybe there is a wonder hack to achieve this ?



Question n°3:


Let’s imagine that the “display” problem is adressed and that we use “Application-Level Windows” , what would be the recommandation in Vaadin to
synchronize the two windows ? Refresher, ServerPush other ?
(The application will be used by a limited number of user, however is it reasonible to have a refresher polling every 1s for changes ?)

Thanks in advance for your feedback and answers.

E.

Yes, “Application-Level Windows” is the way to go. Which approach (named pre-created window or custom getWindow()) depends on your needs. Overriding getWindow() is usually the most flexible approach, though.

AFAIK not very feasible, unfortunately. You might be able to move the opened window to the other screen using javascript on some OS, but I tried this and it does not work on Mac Chrome, at least. YMMV. Other than that approach, all I can think of is using some even more native/browser specific stuff - extensions, perhaps. Or maybe using java Robot, but I seem to recall that’s buggy on multiple displays also…

Note that this is AFAIK - it’s totally possible there is some awesome hack for this.

While we’re at it: do you have to support a wide range of platforms, or are you targeting a specific browser/os combination?

A polling request that does not return any changes is actually very light-weight in Vaadin. It is still a request, though.
For push, you can choose one of the several add-ons, although they are all experimental/beta at this point. My impression is that Dontpush-ozonelayer is the state of the art, you might want to try that: http://vaadin.com/directory#addon/dontpush-ozonelayer Notice the ‘experimental’ tag, though. But I do think Matti and Mark will prove pretty responsive if you provide feedback for the add-on :wink:

Those were my thoughts on this, hope some of it was useful.

Best Regards,
Marc

Marc (and all reading),

for my “Question 2” regarding the possibility to position directly a second “native” window, here is some simple hack I’m exploring

	  String script  = "this.moveTo(1024,0);"; 
      executeJavaScript(script);

This code is in the “native window” class constructor. My idea would be the following, obtain the screen resolution and use this trick to move the popup native window to the desired location.

do you think it’s a path worst trying ?

(btw thanks the response, I’ve more or less all the rest working, including the ozonelayer pish.)

This is basically what I tried (moveTo() in plain JS in the browser console), and on Mac/Chrome it did not work - the window stops at the screen border. However, on other platforms it might work - that’s the impression I got while googling, anyway.

Best Regards,
Marc

ok confirmation to what you were saying … basically it does not work :bashful:, probably for some security reason, browsers prevent the native window to be displayed outside the range of the primary display … so indeed it stop the “move” at the borders of the main display …

I’ll keep hunting for a crazy hack on this, but current solution is for the users to move manually the native window.

Hi Eric,

have you tried the following to open the second window?

Window win = new SecondWindow();
getApplication().getMainWindow().executeJavaScript(
                    "window.open('" + win.getURL() + "', '_blank', 'left=1400, top=0')");

Regards

Andreas

Thanks Andreas for the hint.

I’ve the following code working the way I want but only on IE:

getMainWindow().executeJavaScript("myWindow = window.open('" + secondWindow.getURL() + "', '_blank', 'width=1920', 'height=1080')");
getMainWindow().executeJavaScript("myWindow.moveTo(1920, 0)");

on firefox and chrome, native popup window remains in “principal display”. :glare:

still your hint of moving window after with some javascript helped me, I’ll keep diffing in this direction.