Class BrowserTabInterceptor2
java.lang.Object
org.apache.struts2.interceptor.AbstractInterceptor
com.opensymphony.xwork2.interceptor.AbstractInterceptor
name.matthewgreet.strutscommons.interceptor.BrowserTabInterceptor2
- All Implemented Interfaces:
com.opensymphony.xwork2.interceptor.ConditionalInterceptor
,com.opensymphony.xwork2.interceptor.Interceptor
,Serializable
,org.apache.struts2.interceptor.ConditionalInterceptor
,org.apache.struts2.interceptor.Interceptor
public class BrowserTabInterceptor2
extends com.opensymphony.xwork2.interceptor.AbstractInterceptor
If the action implements BrowserTabAware, sets tab id from cookies. The requesting web page must be set up for this
to be correct. See
ServletLibrary.getBrowserTabId(javax.servlet.http.Cookie[])
. This differs from BrowserTabInterceptor by detecting a
user has opened a link in a new tab and copying data from the old tab so the user can treat them as independent.
See Struts 2 - Server State per Browser Tab, Injected Per-tab Session
for more details of how this works.
Interceptor parameters
- disabled
- If true, all processing is disabled. Defaults to false.
Extending the interceptor
The following methods can be overridden :-
- attributeCloneAction
- Whether to ignore, copy or clone a tab-specific attribute of the old tab.
- attributeFromOldTabToNewClone
- Clones a private, tab-specific attribute from the old tab to the new.
- attributeFromOldTabToNewCopyConstructor
- Copies a private, tab-specific attribute from the old tab to the new using the copy constructor.
- attributeFromOldTabToNewCopyReference
- Copies reference to a private, tab-specific attribute from the old tab to the new.
- attributeFromOldTabToNewIgnore
- Notification that a private, tab-specific attribute found in the old tab will not be copied.
- attributeFromOldTabToNewNull
- Copies null value of a private, tab-specific attribute from the old tab to the new.
- attributesFromOldTabToNewTab
- Copies private, tab-specific attributes from the old tab to the new by various means.
Example code
@InterceptorRefs({ @InterceptorRef(value="browserTab2"), @InterceptorRef(value="defaultStack") })
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface com.opensymphony.xwork2.interceptor.ConditionalInterceptor
com.opensymphony.xwork2.interceptor.ConditionalInterceptor.LegacyAdapter
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionattributeCloneAction
(BrowserTabAware2 browserTabAware, com.opensymphony.xwork2.ActionInvocation invocation, String attributeName, Object attributeValue) Returns what to do with existing attributes of an existing page if the user is opening a hyperlink in a new browser tab.protected boolean
attributeFromOldTabToNewTabClone
(BrowserTabAware2 browserTabAware, com.opensymphony.xwork2.ActionInvocation invocation, BrowserTabSession oldBrowserTabSession, BrowserTabSession newBrowserTabSession, Map.Entry<String, Object> oldAttributeEntry) Handles an attribute from the old tab that should be cloned and returns whether it succeeded.protected boolean
attributeFromOldTabToNewTabCopyConstructor
(BrowserTabAware2 browserTabAware, com.opensymphony.xwork2.ActionInvocation invocation, BrowserTabSession oldBrowserTabSession, BrowserTabSession newBrowserTabSession, Map.Entry<String, Object> oldAttributeEntry) Handles an attribute from the old tab that that should be copied with a copy constructor and returns whether it succeeded.protected boolean
attributeFromOldTabToNewTabCopyReference
(BrowserTabAware2 browserTabAware, com.opensymphony.xwork2.ActionInvocation invocation, BrowserTabSession oldBrowserTabSession, BrowserTabSession newBrowserTabSession, Map.Entry<String, Object> oldAttributeEntry) Handles an attribute from the old tab that where its reference should be copied and returns whether it succeeded.protected boolean
attributeFromOldTabToNewTabIgnore
(BrowserTabAware2 browserTabAware, com.opensymphony.xwork2.ActionInvocation invocation, BrowserTabSession oldBrowserTabSession, BrowserTabSession newBrowserTabSession, Map.Entry<String, Object> oldAttributeEntry) Handles an attribute from the old tab that should be ignored and returns whether it succeeded, which does nothing.protected boolean
attributeFromOldTabToNewTabNull
(BrowserTabAware2 browserTabAware, com.opensymphony.xwork2.ActionInvocation invocation, BrowserTabSession oldBrowserTabSession, BrowserTabSession newBrowserTabSession, Map.Entry<String, Object> oldAttributeEntry) Handles an attribute from the old tab that that has a null value and returns whether it succeeded.protected void
attributesFromOldTabToNewTab
(BrowserTabAware2 browserTabAware, com.opensymphony.xwork2.ActionInvocation invocation, BrowserTabSession oldBrowserTabSession, BrowserTabSession newBrowserTabSession) Called when the user's web browser reloads because the page has been opened in a new tab, to copy private, tab-specific attributes from the old tab to the new.boolean
protected String
getTabId
(com.opensymphony.xwork2.ActionInvocation invocation) intercept
(com.opensymphony.xwork2.ActionInvocation invocation) void
setDisabled
(boolean disabled) Methods inherited from class com.opensymphony.xwork2.interceptor.AbstractInterceptor
intercept, shouldIntercept, shouldIntercept
Methods inherited from class org.apache.struts2.interceptor.AbstractInterceptor
destroy, init, setDisabled
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.struts2.interceptor.Interceptor
destroy, init
-
Constructor Details
-
BrowserTabInterceptor2
public BrowserTabInterceptor2()
-
-
Method Details
-
attributeCloneAction
protected BrowserTabInterceptor2.AttributeCloneAction attributeCloneAction(BrowserTabAware2 browserTabAware, com.opensymphony.xwork2.ActionInvocation invocation, String attributeName, Object attributeValue) Returns what to do with existing attributes of an existing page if the user is opening a hyperlink in a new browser tab. -
attributeFromOldTabToNewTabClone
protected boolean attributeFromOldTabToNewTabClone(BrowserTabAware2 browserTabAware, com.opensymphony.xwork2.ActionInvocation invocation, BrowserTabSession oldBrowserTabSession, BrowserTabSession newBrowserTabSession, Map.Entry<String, Object> oldAttributeEntry) Handles an attribute from the old tab that should be cloned and returns whether it succeeded. -
attributeFromOldTabToNewTabCopyConstructor
protected boolean attributeFromOldTabToNewTabCopyConstructor(BrowserTabAware2 browserTabAware, com.opensymphony.xwork2.ActionInvocation invocation, BrowserTabSession oldBrowserTabSession, BrowserTabSession newBrowserTabSession, Map.Entry<String, Object> oldAttributeEntry) Handles an attribute from the old tab that that should be copied with a copy constructor and returns whether it succeeded. -
attributeFromOldTabToNewTabCopyReference
protected boolean attributeFromOldTabToNewTabCopyReference(BrowserTabAware2 browserTabAware, com.opensymphony.xwork2.ActionInvocation invocation, BrowserTabSession oldBrowserTabSession, BrowserTabSession newBrowserTabSession, Map.Entry<String, Object> oldAttributeEntry) Handles an attribute from the old tab that where its reference should be copied and returns whether it succeeded. -
attributeFromOldTabToNewTabIgnore
protected boolean attributeFromOldTabToNewTabIgnore(BrowserTabAware2 browserTabAware, com.opensymphony.xwork2.ActionInvocation invocation, BrowserTabSession oldBrowserTabSession, BrowserTabSession newBrowserTabSession, Map.Entry<String, Object> oldAttributeEntry) Handles an attribute from the old tab that should be ignored and returns whether it succeeded, which does nothing. -
attributeFromOldTabToNewTabNull
protected boolean attributeFromOldTabToNewTabNull(BrowserTabAware2 browserTabAware, com.opensymphony.xwork2.ActionInvocation invocation, BrowserTabSession oldBrowserTabSession, BrowserTabSession newBrowserTabSession, Map.Entry<String, Object> oldAttributeEntry) Handles an attribute from the old tab that that has a null value and returns whether it succeeded. -
attributesFromOldTabToNewTab
protected void attributesFromOldTabToNewTab(BrowserTabAware2 browserTabAware, com.opensymphony.xwork2.ActionInvocation invocation, BrowserTabSession oldBrowserTabSession, BrowserTabSession newBrowserTabSession) Called when the user's web browser reloads because the page has been opened in a new tab, to copy private, tab-specific attributes from the old tab to the new. -
getTabId
-
getDisabled
public boolean getDisabled() -
setDisabled
public void setDisabled(boolean disabled) -
intercept
- Specified by:
intercept
in interfacecom.opensymphony.xwork2.interceptor.Interceptor
- Specified by:
intercept
in classcom.opensymphony.xwork2.interceptor.AbstractInterceptor
- Throws:
Exception
-