This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSF and the fly likes Open New Window using h:commandButton Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Open New Window using h:commandButton" Watch "Open New Window using h:commandButton" New topic
Author

Open New Window using h:commandButton

Varshini Priya
Ranch Hand

Joined: Feb 17, 2008
Posts: 93

I need some help on how to open a page in a new Tab on click of the command button. I know I can acheive this using the javascript. But I would like to acheive this using JSF code and not Javascript. Im using JSF2.0. I have already been able to establish this using commandLink by adding target="_blank". But I would like to acheive the same using commandButton. Also is there anyway if we can specify the javascript code in the backend to open the page in a new tab?? please assist.
Thanks in Advance
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15961
    
  19

The JSF commandButton control does not support the target attribute, unlike the commandLink. What most people do is fake it by decorating a commandLink to look like a button.

None of the popular J2EE servers have JavaScript interpreters built into them, so any JavaScript code would have to run on the client.


Customer surveys are for companies who didn't pay proper attention to begin with.
Varshini Priya
Ranch Hand

Joined: Feb 17, 2008
Posts: 93

Thanks for the response Tim. I was able to acheive this via the below code . Thought of sharing it, since it might be useful for someone else.


 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Open New Window using h:commandButton
 
Similar Threads
how to open page in new tab
Javascript
Expiring session
How to display an image while waiting for PDF to render?
Open JSP page in new tab(browser) from request from servlet