Class WTimeoutWarning
- java.lang.Object
-
- com.github.bordertech.wcomponents.AbstractWComponent
-
- com.github.bordertech.wcomponents.WTimeoutWarning
-
- All Implemented Interfaces:
WComponent
,WebComponent
,Serializable
public class WTimeoutWarning extends AbstractWComponent
WTimeoutWarning provides a mechanism to pass a session timeout period in seconds to the client. This can then be used to indicate to the user when their session is about to expire.This has two purposes: firstly it provides a means to minimise data loss by users by indicating that they should submit their work before the session expires; and secondly it is a WCAG requirement that users be given a warning of the end of a time-limited process and a means to extend that limit.
If the timeout period is "zero", then use the http session timeout interval will be used. If a user's session does not expire then an existing WTimeoutWarning can have its timeout set to -1. This will prevent painting the WTimeoutWarning. This value is the equivalent of a http session time out value of -1 which indicates that the session does not time out.
- Since:
- 1.0.0
- Author:
- Mark Reeves
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
WTimeoutWarning.TimeoutWarningModel
Extends ComponentModel to provide timeout and warning periods to be set.-
Nested classes/interfaces inherited from class com.github.bordertech.wcomponents.AbstractWComponent
AbstractWComponent.WComponentRef
-
-
Field Summary
-
Fields inherited from interface com.github.bordertech.wcomponents.WComponent
DEFAULT_APPLICATION_ID, DEFAULT_INTERNAL_ID, DEFAULT_NO_ID, ID_CONTEXT_SEPERATOR, ID_FRAMEWORK_ASSIGNED_SEPERATOR, ID_VALIDATION_PATTERN
-
-
Constructor Summary
Constructors Constructor Description WTimeoutWarning()
Creates a WTimeoutWarning using default timeout and warning settings.WTimeoutWarning(int timeoutPeriod)
Creates a timeout indicator with a timeout period and uses the default warning period.WTimeoutWarning(int timeoutPeriod, int warningPeriod)
Creates a timeout indicator with both a timeout period and warning period
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected WTimeoutWarning.TimeoutWarningModel
getComponentModel()
Returns the effective component model for this component.protected WTimeoutWarning.TimeoutWarningModel
getOrCreateComponentModel()
Retrieves the model for this component so that it can be modified.int
getTimeoutPeriod()
Get the indicated timeout period.int
getWarningPeriod()
Get the warning period.protected WTimeoutWarning.TimeoutWarningModel
newComponentModel()
Creates a new model appropriate for the type of component.protected void
preparePaintComponent(Request request)
Initialise by setting the timeout to the HTTPSession maxInactiveInterval if the timeoutPeriod has not yet been set.void
setTimeoutPeriod(int timeoutPeriod)
Set a timeout indicator for a specified number of seconds.void
setWarningPeriod(int warningPeriod)
Set a pre-timeout warning to a specified number of seconds.-
Methods inherited from class com.github.bordertech.wcomponents.AbstractWComponent
addHtmlClass, addHtmlClass, addNotify, afterPaint, assertAddSupported, beforePaint, createErrorDiagnostic, createErrorDiagnostic, forward, getAccessibleText, getAttribute, getBaseUrl, getDefaultModel, getEnvironment, getHeaders, getHtmlClass, getHtmlClasses, getId, getIdName, getInternalId, getLabel, getName, getParent, getScratchMap, getTabIndex, getTag, getTemplate, getTemplateMarkUp, getToolTip, handleRequest, hasNoComponentModel, hasTabIndex, initialiseComponentModel, invokeLater, invokeLaters, isDebugStructure, isDefaultState, isFlagSet, isHidden, isInitialised, isLocked, isTracking, isTrackingEnabled, isValidate, isVisible, paint, paintComponent, preparePaint, removeAttribute, removeComponentModel, removeHtmlClass, removeHtmlClass, removeNotify, replaceWComponent, reset, serviceRequest, setAccessibleText, setAttribute, setEnvironment, setFlag, setFocussed, setHidden, setHtmlClass, setHtmlClass, setIdName, setInitialised, setLocked, setTag, setToolTip, setTrackingEnabled, setValidate, setVisible, showErrorIndicators, showErrorIndicatorsForComponent, showWarningIndicators, showWarningIndicatorsForComponent, tidyUpUIContext, tidyUpUIContextForTree, toString, validate, validateComponent, writeReplace
-
-
-
-
Constructor Detail
-
WTimeoutWarning
public WTimeoutWarning()
Creates a WTimeoutWarning using default timeout and warning settings.
-
WTimeoutWarning
public WTimeoutWarning(int timeoutPeriod, int warningPeriod)
Creates a timeout indicator with both a timeout period and warning periodIf the timeout period is "zero", then use the http session timeout interval will be used.
- Parameters:
timeoutPeriod
- The timeout in seconds. This should be slightly less than the shortest timeout period in the entire application stack, not just the web server session timeout.warningPeriod
- The time in seconds before the time out occurs in which the warning indicator should show. There is a minimum for this which is determined by the Web Content Accessibility Guidelines 2.0.
-
WTimeoutWarning
public WTimeoutWarning(int timeoutPeriod)
Creates a timeout indicator with a timeout period and uses the default warning period.If the timeout period is "zero", then use the http session timeout interval will be used.
- Parameters:
timeoutPeriod
- The timeout in seconds.
-
-
Method Detail
-
setTimeoutPeriod
public void setTimeoutPeriod(int timeoutPeriod)
Set a timeout indicator for a specified number of seconds.If the timeout period is "zero", then the session timeout interval will be used.
- Parameters:
timeoutPeriod
- the timeout in seconds.
-
setWarningPeriod
public void setWarningPeriod(int warningPeriod)
Set a pre-timeout warning to a specified number of seconds. This should be no less than the WCAG minimum of 20.Setting the warning period to exactly ZERO (0) allows the warning time to be determined in the client layer.
- Parameters:
warningPeriod
- The timeout warning will show this many seconds before the timeout as indicated by the timeoutPeriod.
-
getTimeoutPeriod
public int getTimeoutPeriod()
Get the indicated timeout period.- Returns:
- The timeout period in seconds.
-
getWarningPeriod
public int getWarningPeriod()
Get the warning period.- Returns:
- The warning period in seconds.
-
preparePaintComponent
protected void preparePaintComponent(Request request)
Initialise by setting the timeout to the HTTPSession maxInactiveInterval if the timeoutPeriod has not yet been set. Subclasses may override this method to place the component in the correct state before it is painted. When overriding this method, it is good practice to also call the superclass implementation.- Overrides:
preparePaintComponent
in classAbstractWComponent
- Parameters:
request
- the request being responded to.
-
newComponentModel
protected WTimeoutWarning.TimeoutWarningModel newComponentModel()
Creates a new model appropriate for the type of component. Subclasses can override, and should narrow the return type.- Overrides:
newComponentModel
in classAbstractWComponent
- Returns:
- a new ComponentModel.
-
getComponentModel
protected WTimeoutWarning.TimeoutWarningModel getComponentModel()
Returns the effective component model for this component. Subclass may override this method to narrow the return type to their specific model type.- Overrides:
getComponentModel
in classAbstractWComponent
- Returns:
- the effective component model
-
getOrCreateComponentModel
protected WTimeoutWarning.TimeoutWarningModel getOrCreateComponentModel()
Retrieves the model for this component so that it can be modified. If this method is called during request processing, and a session specific model does not yet exist, then a new model is created. Subclasses may override this method to narrow the return type to their specific model type.- Overrides:
getOrCreateComponentModel
in classAbstractWComponent
- Returns:
- the model for this component
-
-