This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JSF and the fly likes Open commandLink in new tab/window Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "Open commandLink in new tab/window" Watch "Open commandLink in new tab/window" New topic
Author

Open commandLink in new tab/window

Ad Tan
Greenhorn

Joined: Oct 30, 2009
Posts: 22
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
Saloon Keeper

Joined: Jun 25, 2001
Posts: 14475
    
    7

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Ad Tan
Greenhorn

Joined: Oct 30, 2009
Posts: 22
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
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Open commandLink in new tab/window
 
Similar Threads
jsf and servlets
Refresh the previous page
How to go back to a page
Problem in setting view root in beforeRenderResponse()
Inject SessionScoped Bean in ViewScoped Bean