0

I would like to click a link and redirect to an external URL in a new window.

<h:commandLink value="Test" target="_blank" action="#{bean.openWindow}" />   
public String openWindow() {
    return "http://www.google.com";
}

But it is just not working. My browser has opened a new window. But the window is showing the same page instead of the external URL.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
user1386463
  • 171
  • 1
  • 3
  • 16
  • The return value of the action method is expected to be a navigation case outcome which is untrue in your case. If no bean logic is to be executed upon clicking the link, then simply use `Test Popup` instead. – Tiny Aug 04 '15 at 03:02
  • The outputLink is worked for display google now. Thx Tiny. How about if I would like to redirect to some page contains some logic. How can I do? I know I should use commandLink this moment. When I changed to public String PopupWindow() {return "popupWindow";} and keep the commandLink part. I also have the page called popupWindow.jspx. But still not working. The page popup a new window, but display the same page instead of popupWindow.jspx. – user1386463 Aug 04 '15 at 03:14
  • http://stackoverflow.com/a/4317723/1391249 (I am not practically aware of old JSPX). – Tiny Aug 04 '15 at 03:20
  • public void openWindow() { ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext(); externalContext.redirect("http://www.google.com"); } – itro Jan 24 '20 at 15:00

0 Answers0