I upgraded from MyFaces 1.1.4 to 1.2.2 only to find out all the popups used
throughout the app would no longer open; instead, a blank popup page
appeared along with an indication of a JavaScript error. I believe the issue
is related to a change in the MyFaces auto-generated JavaScript; here is a
small demo app that demonstrated the problem:
popupDemo.xhtml:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:t="http://myfaces.apache.org/tomahawk">
<head>
<script language="JavaScript1.1">
/* <![CDATA[ */
function doPopup(height,width,form,target) {
var xOffset = (height - 300)/2, yOffset =
(width - 690)/2;
features="height=" + height + ",width=" + width
+
",screenX="+xOffset+",screenY="+yOffset+",top="+
yOffset+",left="+xOffset+",menubar=no,titlebar=no,scrollbars=yes";
popup = window.open("", "popup", features);
//popup.openerFormId = source.form.id;
popup.focus();
var hidden = document.forms.hidden;
// Unlike the Sun JSF Reference Impl, My Faces
generates _link_hidden
// input field for each invisible link; the
following line is used to
// emulate the action link being clicked.
hidden[form+":_link_hidden_"].value = form+":"+target;
//hidden["hidden:param"].value =
form+":"+target;
// Submit the hidden form. The output will be
sent to the just opened
window.
hidden.submit();
}
/* ]]> */
</script>
<title>Popup Demo Page</title>
</head>
<body>
<h:form>
<h:commandButton value="..." immediate="true"
onmousedown="doPopup(590,690,'hidden','goTestPopup')"
onclick="return false" />
</h:form>
<!-- This hidden form sends a request to a popup window. -->
<h:form id="hidden" target="popup">
<!-- The hidden input field(s) bellow can be used to
pass info from the parent page to the popup. -->
<!-- h:inputHidden id="param" value="" / -->
<!-- The action attribute of the command link bellow
is used by the JSF navigation handler to select
the JSF page that generates the popup
contents. -->
<h:commandLink id="goTestPopup" action="testPopup" value="">
<f:verbatim />
</h:commandLink>
</h:form>
</body>
</html>
Can anyone please suggest a solution? I am not a JavaScript expert, and the
code used to open popups was copied from an example in the Core JSF book.
Many thanks,
Mihajlo
--
View this message in context:
http://www.nabble.com/Popups-Broken-After-Upgrade-to-MyFaces-1.2.2-tp16711347p16711347.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.