Programming Thoughts
Struts 2 - Server State per Browser Tab
Popups
The same page in different browser tabs that don't interfere with each other, improved
Users expect pages in different tabs to not interfere with each other's session data, even if they're the same page but for different records. The previous article detects when a users open a link in a new tab, thereby confusing tab identification and requiring copying of per-tab session data. This article handles each tab having its own set of floating browser windows.
Floating popup windows
Some users prefer viewing related record data not shown on the current page as a separate, free-floating window. The screenshot below illustrates this.

Figure 1: Free-floating window
The problem is popup windows are identified by their window name, interfering with using window name as tab id. The easy solution is to append the tab id to a window name ending with '_popup_' and server side code looks for that string.
Change to server code
The code below shows what needs to be changed.
public static final String COOKIE_NAME_POPUP_MARKER = "_popup_"; public static String getBrowserTabId(Cookie[] cookies) { String result; result = null; if (cookies != null) { for (Cookie cookie: cookies) { if (cookie.getName().equals(TAB_ID_COOKIE_NAME)) { result = cookie.getValue(); break; } } } if (result.contains(COOKIE_NAME_POPUP_MARKER)) { result = result.substring(result.indexOf(COOKIE_NAME_POPUP_MARKER) + COOKIE_NAME_POPUP_MARKER.length()); } return result; }
Example JavaScript
Creating popup windows requires adding the tab id to the window name, like the following.
<BUTTON CLASS="action_button" TYPE="BUTTON" onclick="window.open('<s:url value="/ViewRatingDistributionListPopup.action" />', 'rating_distribution_popup_' + getTabId(), 'top=700,height=460,width=400,location=no,menubar=no,status=no,titlebar=no');" >Rating Distribution Popup...</BUTTON>
Example
A working example can be downloaded from Example.