• Post Reply Bookmark Topic Watch Topic
  • New Topic

Open commandLink in new tab/window

 
Ad Tan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I'm using JSF2 and I have pageA and pageB, where pageA have a table where each row is a record, let's call it entityX.

When a record is selected via commandLink, the details can be viewed in pageB.

So the details are displayed in pageB via MBeanB...

Normally, this approach works well. However, if I choose to open the link in a new tab/window, it will open pageB directly without going through the select method in MBeanA. My question is, how can I change the commandLink to always go through the same workflow, regardless if the target is the same window or a new tab/window.

BTW, I can't use commandButton for some reasons... and my users require multi-tab functionalities.

Thanks!

Ad
 
Tim Holloway
Bartender
Posts: 18417
60
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are 2 reasons to avoid opening secondary windows in JSF webapps:

1. JSF doesn't support separate workflows and confusion may result since the same beans that the original page employed are also going to be used in the secondary page, except in the case of Request Scope beans, where each request gets its own bean anyway. View Scope is just a modified Session Scope and I'm suspecting that Flash Scope is going to likewise have conflicts.

2. It really annoys me as a user to have pages (or in my case, tabs) popping up all over the place.

You showed us what your backing bean code looks like, but to open a page in a new window, you have to code the commandLink tag properly (commandButton does not support "open in new window", BTW). So if you could include the commandLink definition that would be most helpful.
 
Ad Tan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For my case, it is not really whether multi-tabs should be available, but my concerns are with unknown behavior, there might be potential security issues, ie, users may be able to make use of multi-tab to access entities that are normally unavailable.

Anyway, to resolve this issue, what I have done is to provide the following:
1. Use a commandButton instead, which prevents opening new tabs (hopefully, haven't test which browser plugins still allows that)
2. Use a commandLink but change target to "_blank", thus forcing a new tab/window.

Ad
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!