Reputation: 10778
Using Primefaces 4.0 and JSF 2.2.
I would like to send the visitor to a page in a new window (not tab). The landing page is a jsf page called grade.xhtml
I tried:
<h:commandLink value="OK" onclick="window.open('grade.html', 'newwindow','width=300, height=300'); return false;"/>
This gets to a 404. Obviously this is all happening client side so grade.html doesn't get generated from grade.xhtml
. How should I do?
Note: if I put onclick="window.open('grade.xhtml', 'newwindow','width=300, height=300'); return false;"
then the page does open, but it is the jsf (xhtml code) not html version that shows up.
Upvotes: 2
Views: 9217
Reputation: 3
Open the URL in new window from JSF controller.
HttpServletResponse res = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
HttpServletRequest req = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
String uri = req.getRequestURI();
res.getWriter().println("<script>window.open('" + myUrl + "','_blank', 'location=yes,height=600,width=800,scrollbars=yes,status=yes'); window.parent.location.href= '"+uri+"';</script>");
FacesContext.getCurrentInstance().responseComplete();
Upvotes: 0
Reputation: 86
I use javaScript for this.. Try it:
<script type="text/javascript" language="javascript">
function funcForWindowPopup()
{
var popup = null;
popup = window.open("grade.xhtml", "popup", "toolbar=no,menubar=no,scrollbars=yes,location=no,left=350,top=50,width=650, height=600");
popup.openerFormId = "formID";
popup.focus();
}
</script>
You can change parameters as you need;)
Upvotes: 2
Reputation: 1004
try this:
<h:commandLink value="OK" action="grade.xhtml" target="_blank"/>
Look an example here: When i click on any link it should Open in the same New Window in JSF, Primefaces
Upvotes: 3