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 booleanattributeFromOldTabToNewTabClone(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 booleanattributeFromOldTabToNewTabCopyConstructor(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 booleanattributeFromOldTabToNewTabCopyReference(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 booleanattributeFromOldTabToNewTabIgnore(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 booleanattributeFromOldTabToNewTabNull(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 voidattributesFromOldTabToNewTab(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.booleanprotected StringgetOldTabId(com.opensymphony.xwork2.ActionInvocation invocation) Returns previous tab id when page detects it's in a new browser tab, or empty string if not applicable.protected StringgetTabId(com.opensymphony.xwork2.ActionInvocation invocation) Returns tab id of current browser tab, creating it if one doesn't exist.intercept(com.opensymphony.xwork2.ActionInvocation invocation) voidsetDisabled(boolean disabled) Methods inherited from class com.opensymphony.xwork2.interceptor.AbstractInterceptor
intercept, shouldIntercept, shouldInterceptMethods inherited from class org.apache.struts2.interceptor.AbstractInterceptor
destroy, init, setDisabledMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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. -
getOldTabId
Returns previous tab id when page detects it's in a new browser tab, or empty string if not applicable. -
getTabId
Returns tab id of current browser tab, creating it if one doesn't exist. -
getDisabled
public boolean getDisabled() -
setDisabled
public void setDisabled(boolean disabled) -
intercept
- Specified by:
interceptin interfacecom.opensymphony.xwork2.interceptor.Interceptor- Specified by:
interceptin classcom.opensymphony.xwork2.interceptor.AbstractInterceptor- Throws:
Exception
-