You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by Apache Wiki <wi...@apache.org> on 2007/02/25 15:28:38 UTC
[Myfaces Wiki] Update of "JavascriptOpenNewWindow" by Rene Grob
Dear Wiki user,
You have subscribed to a wiki page or wiki category on "Myfaces Wiki" for change notification.
The following page has been changed by Rene Grob:
http://wiki.apache.org/myfaces/JavascriptOpenNewWindow
New page:
= How to open a new browser window from my JSF page? =
The article describes different ways to open a new browser window from a JSF page and the involved advantages and drawbacks.
== Using the "target" attribute of the commandLink component ==
{{{
<h:commandLink target="popupWindow" action="navigateToPopup" actionListener="#{bean.linkClicked}" value="open popup" />
}}}
This approach has many drawbacks:
* In Fire''''''Fox a new tab is opened instead of a new browser window.
* The browser window is opened although there are validation errors.
* Validation errors are displayed in the newly opened window which is very confusing.
* The appearance of the new window cannot be controlled (e.g. hiding of the location bar)
If no model updated is needed then setting the attribute "immediate" to "true" can be used to work around the validation problems.
== Using HTML and Javascript ==
{{{
<a href="#" onclick="window.open('popup.faces', 'popupWindowName', 'dependent=yes, menubar=no, toolbar=no');">open popup</a>
}}}
With this solution we got control over the appearance of the new browser window. And since there is no postback, there is no validation at all.
This is the easiest way to open a new browser window when no model update is needed and no action has to be executed.