wood burning stoves 2.0*
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


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: 16101
    
  21

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.


 
GeeCON Prague 2014
 
subject: Open New Window using h:commandButton