• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Open New Window using h:commandButton

 
Varshini Priya
Ranch Hand
Posts: 95
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 17989
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Varshini Priya
Ranch Hand
Posts: 95
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic