New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include enable function in OmniFaces.Unload #326

Closed
hrkistiansen opened this Issue Nov 8, 2016 · 3 comments

Comments

Projects
None yet
2 participants
@hrkistiansen

hrkistiansen commented Nov 8, 2016

It would be nice if there was some hook to re-enable the unload-event, even after a non-ajax submit.

We have a use case where a submit action returns a dynamic link which opens in a new window. The unload-event on the origin page is disabled by the submit action, and we have found no obvious way to aviod this behaviour, or re-enable unload-event.

Regards,
Håvard

@BalusC

This comment has been minimized.

Show comment
Hide comment
@BalusC

BalusC Nov 16, 2016

Member

Reproducer:

<h:form target="_blank">
    <h:commandButton action="#{omniViewScopedBean.submit}" />
</h:form>
Member

BalusC commented Nov 16, 2016

Reproducer:

<h:form target="_blank">
    <h:commandButton action="#{omniViewScopedBean.submit}" />
</h:form>
@BalusC

This comment has been minimized.

Show comment
Hide comment
@BalusC

BalusC Nov 16, 2016

Member

This is a nasty corner case. Another issue is that the view scoped bean of parent page gets unloaded when child window is closed while parent window is still open.

On the other hand, I'm not sure about your concrete functional requirement, but you should at least know that navigation by POST is a bad practice. Consider replacing <h:form target="_blank"> by <script>window.open(...)</script>. Related links:

Member

BalusC commented Nov 16, 2016

This is a nasty corner case. Another issue is that the view scoped bean of parent page gets unloaded when child window is closed while parent window is still open.

On the other hand, I'm not sure about your concrete functional requirement, but you should at least know that navigation by POST is a bad practice. Consider replacing <h:form target="_blank"> by <script>window.open(...)</script>. Related links:

@hrkistiansen

This comment has been minimized.

Show comment
Hide comment
@hrkistiansen

hrkistiansen Nov 16, 2016

Thank you for the update. The corner is even darker than you think.

In IE 10/11 the browser treats window.open and <a target="_blank" differently than <form target="_blank". But only if the parent window was opened by another window, and the user has the setting "always open pop-ups in new window", and the originating page uses PrimeFaces <p:poll. Using <form target="_blank" is the only way we have found to prevent the pop-up window to hide behind the originating window in this rather narrow corner case.

Of course, all is fine if the parent window is opened directly by the user, or the browser setting is anything but "always open pop-ups in new window", or parent page does not use a <p:poll, or using any other browser.

We tried any number of ways to remedy this window-behaviour, but in the end settled for submit, re-enabling the unload-event, and getting on with our lives. Hence the request for an official hook to re-enable the unload event :-)

hrkistiansen commented Nov 16, 2016

Thank you for the update. The corner is even darker than you think.

In IE 10/11 the browser treats window.open and <a target="_blank" differently than <form target="_blank". But only if the parent window was opened by another window, and the user has the setting "always open pop-ups in new window", and the originating page uses PrimeFaces <p:poll. Using <form target="_blank" is the only way we have found to prevent the pop-up window to hide behind the originating window in this rather narrow corner case.

Of course, all is fine if the parent window is opened directly by the user, or the browser setting is anything but "always open pop-ups in new window", or parent page does not use a <p:poll, or using any other browser.

We tried any number of ways to remedy this window-behaviour, but in the end settled for submit, re-enabling the unload-event, and getting on with our lives. Hence the request for an official hook to re-enable the unload event :-)

@BalusC BalusC closed this in 5f99eac Nov 25, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment