Class WTabSet
- java.lang.Object
-
- com.github.bordertech.wcomponents.AbstractWComponent
-
- com.github.bordertech.wcomponents.AbstractContainer
-
- com.github.bordertech.wcomponents.AbstractNamingContextContainer
-
- com.github.bordertech.wcomponents.WTabSet
-
- All Implemented Interfaces:
AjaxTarget
,Container
,Disableable
,Marginable
,NamingContextable
,SubordinateTarget
,WComponent
,WebComponent
,Serializable
public class WTabSet extends AbstractNamingContextContainer implements Disableable, AjaxTarget, Marginable, SubordinateTarget
This component enables rendering of a set of tabbed components.
A
WTabSet
WComponent has the following functionality:- The ability to render as different types of client-side tab controls.
- The ability to process each tab control on the client side (via JavaScript) or Server side processing.
- The ability to set the active tab(s). By default it is the first in the list and can be set via the following
methods:
setActiveIndex(int)
to set the active tab as the index corresponding to the order of tabs at construction time.setActiveTab(WComponent)
to set the active tab that matches the WComponent supplied at construction time (seeaddTab(WComponent, String, TabMode)
).
NOTE: When setting the tab set type to be LEFT or RIGHT you should make use of the method
setContentHeight(String)
to provide a sensible default height for the tab set. Otherwise, it will default to the height of one tab.- Since:
- 1.0.0
- Author:
- Yiannis Paschalidis
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
WTabSet.TabMode
The available types of tab invocation.static class
WTabSet.TabSetModel
Holds the extrinsic state information of a WTabSet.static class
WTabSet.TabSetType
The available types of client-side tab sets.-
Nested classes/interfaces inherited from class com.github.bordertech.wcomponents.AbstractWComponent
AbstractWComponent.WComponentRef
-
-
Field Summary
Fields Modifier and Type Field Description static WTabSet.TabMode
TAB_MODE_CLIENT
A tab mode where tab content is always rendered, and invoking the tab only results in a client-side switch.static WTabSet.TabMode
TAB_MODE_DYNAMIC
A tab mode where invoking the tab will perform an ajax request every time the tab is requested.static WTabSet.TabMode
TAB_MODE_EAGER
A tab mode where invoking the tab will perform an ajax request immediately after the page is loaded.static WTabSet.TabMode
TAB_MODE_LAZY
A tab mode where invoking the tab will perform an ajax request the first time the tab is requested.static WTabSet.TabMode
TAB_MODE_SERVER
Deprecated.Use TAB_MODE_DYNAMIC instead as a like-for-like replacement or any other mode if it is more appropriate to the individual use case.static WTabSet.TabSetType
TYPE_ACCORDION
An "accordion" type tab-set, that supports having multiple open tabs.static WTabSet.TabSetType
TYPE_APPLICATION
Deprecated.1.2.0static WTabSet.TabSetType
TYPE_LEFT
A tab-set where tab buttons are placed to the left of the content.static WTabSet.TabSetType
TYPE_RIGHT
A tab-set where tab buttons are placed to the right of the content.static WTabSet.TabSetType
TYPE_TOP
A tab-set where tab buttons are placed above the content.-
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 WTabSet()
Creates a WTabSet with the tabs positioned on the top.WTabSet(WTabSet.TabSetType type)
Creates a WTabSet of the given type.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
add(WSeparator separator)
Deprecated.separators are not available to tabsets as it does not conform with a11y requirements.void
add(WTab tab)
Deprecated.useaddTab(WComponent, String)
or overloaded version.void
add(WTabGroup group)
Deprecated.Do not use TabGroupsvoid
addSeparator()
Deprecated.separators are not available to tabsets as it does not conform with a11y requirements.WTab
addTab(WComponent content, WDecoratedLabel label)
Adds a LAZY mode tab to the tab set.WTab
addTab(WComponent content, WDecoratedLabel label, char accessKey)
Adds a LAZY tab with a given access key to the tab set.WTab
addTab(WComponent content, WDecoratedLabel label, WTabSet.TabMode mode)
Adds a tab to the tab set.WTab
addTab(WComponent content, WDecoratedLabel label, WTabSet.TabMode mode, char accessKey)
Adds a tab to the tab set.WTab
addTab(WComponent content, String tabName)
Adds a tab to the tab set with a TabMode of LAZY.WTab
addTab(WComponent content, String tabName, char accessKey)
Adds a LAZY tab with a given access key to the tab set.WTab
addTab(WComponent content, String tabName, WTabSet.TabMode mode)
Adds a tab to the tab set.WTab
addTab(WComponent content, String tabName, WTabSet.TabMode mode, char accessKey)
Adds a tab to the tab set.protected WTab
addTab(WTab tab)
Adds aWTab
to the tab set.Action
getActionOnChange()
Deprecated.an action on changing tab is a side-effect and should not be implemented.int
getActiveIndex()
Returns the default active index.List<Integer>
getActiveIndices()
Returns the active indices (as seen by the given context/session).WTab
getActiveTab()
Returns the active tab (as seen by the given context/session).List<WTab>
getActiveTabs()
Returns the active tabs (as seen by the given context/session).protected WTabSet.TabSetModel
getComponentModel()
Returns the effective component model for this component.String
getContentHeight()
String
getGroupName()
The "collapsible" group name that this tabset belongs to.Margin
getMargin()
Get the margin for the component, or null if not set.protected WTabSet.TabSetModel
getOrCreateComponentModel()
Retrieves the model for this component so that it can be modified.WTab
getTab(int index)
Returns the tab at the given index.int
getTabIndex(WComponent content)
Retrieves the tab index for the given tab content.int
getTabIndex(WTab tab)
Retrieves the tab index for the given tab.int
getTotalTabs()
Retrieves the total number of tabs in this tab set.WTabSet.TabSetType
getType()
void
handleRequest(Request request)
Override handleRequest in order to perform processing specific to this component.boolean
isActive(WComponent tab)
Indicates whether the tab is active (selected).boolean
isActive(WTab tab)
Indicates whether the tab is active (selected).boolean
isDisabled()
Indicates whether the WTabSet is disabled in the given context.boolean
isShowHeadOnly()
Deprecated.1.4.7 an irrelevant hangover from a bad design decision - never implemented.boolean
isSingle()
boolean
isTabVisible(int idx)
Indicates whether the tab at the given index is visible.boolean
isTabVisible(WComponent tabContent)
Indicates whether the tab which holds the given content is visible.boolean
isTabVisible(WTab tab)
Indicates whether the tab which holds the given content is visible.protected WTabSet.TabSetModel
newComponentModel()
Creates a new Component model.void
remove(WComponent child)
void
setActionOnChange(Action action)
Deprecated.an action on changing tab is a side-effect and should not be implemented.void
setActiveIndex(int activeIndex)
Sets the active index(as seen by the given context/session).void
setActiveIndices(int[] indices)
Sets the active tab indices (as seen by the given context/session).void
setActiveTab(WComponent content)
Sets the active tab using tab content.void
setActiveTab(WTab tab)
Sets the active tab.void
setContentHeight(String contentHeight)
Sets the content height of the tab set.void
setDisabled(boolean disabled)
Sets whether the WTabSet is disabled.void
setGroup(CollapsibleGroup group)
Set theCollapsibleGroup
that this component belongs to.void
setMargin(Margin margin)
Set the margin for the component, or null for no margin.void
setShowHeadOnly(boolean showHeadOnly)
Deprecated.1.4.7 an irrelevant hangover from a bad design decision - never implemented.void
setSingle(boolean single)
void
setTabVisible(int idx, boolean visible)
Sets the visibility of the tab at the given index.void
setTabVisible(WComponent tabContent, boolean visible)
Sets the visibility of the tab which holds the given content.void
setTabVisible(WTab tab, boolean visible)
Sets the visibility of the tab.String
toString()
Creates a String representation of this component; usually for debugging purposes.-
Methods inherited from class com.github.bordertech.wcomponents.AbstractNamingContextContainer
getNamingContextId, isNamingContext, setNamingContext
-
Methods inherited from class com.github.bordertech.wcomponents.AbstractContainer
getChildAt, getChildCount, getChildren, getIndexOfChild
-
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, hasNoComponentModel, hasTabIndex, initialiseComponentModel, invokeLater, invokeLaters, isDebugStructure, isDefaultState, isFlagSet, isHidden, isInitialised, isLocked, isTracking, isTrackingEnabled, isValidate, isVisible, paint, paintComponent, preparePaint, preparePaintComponent, 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, validate, validateComponent, writeReplace
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.github.bordertech.wcomponents.Container
getChildAt, getChildCount, getChildren, getIndexOfChild
-
Methods inherited from interface com.github.bordertech.wcomponents.WComponent
addHtmlClass, addHtmlClass, forward, getAccessibleText, getAttribute, getBaseUrl, getEnvironment, getHeaders, getHtmlClass, getHtmlClasses, getId, getIdName, getInternalId, getLabel, getName, getParent, getTabIndex, getTag, getToolTip, hasTabIndex, invokeLater, isDefaultState, isHidden, isInitialised, isLocked, isTracking, isTrackingEnabled, isValidate, isVisible, paint, preparePaint, removeAttribute, removeHtmlClass, removeHtmlClass, reset, serviceRequest, setAccessibleText, setAttribute, setEnvironment, setFocussed, setHtmlClass, setHtmlClass, setIdName, setInitialised, setLocked, setTag, setToolTip, setTrackingEnabled, setValidate, setVisible, showErrorIndicators, showWarningIndicators, tidyUpUIContextForTree, validate
-
-
-
-
Field Detail
-
TYPE_TOP
public static final WTabSet.TabSetType TYPE_TOP
A tab-set where tab buttons are placed above the content.
-
TYPE_LEFT
public static final WTabSet.TabSetType TYPE_LEFT
A tab-set where tab buttons are placed to the left of the content.
-
TYPE_RIGHT
public static final WTabSet.TabSetType TYPE_RIGHT
A tab-set where tab buttons are placed to the right of the content.
-
TYPE_ACCORDION
public static final WTabSet.TabSetType TYPE_ACCORDION
An "accordion" type tab-set, that supports having multiple open tabs.
-
TYPE_APPLICATION
public static final WTabSet.TabSetType TYPE_APPLICATION
Deprecated.1.2.0An "application" type tab-set, defined only in a theme.
-
TAB_MODE_SERVER
@Deprecated public static final WTabSet.TabMode TAB_MODE_SERVER
Deprecated.Use TAB_MODE_DYNAMIC instead as a like-for-like replacement or any other mode if it is more appropriate to the individual use case.A synonym for TabMode.TAB_MODE_DYNAMIC.
-
TAB_MODE_LAZY
public static final WTabSet.TabMode TAB_MODE_LAZY
A tab mode where invoking the tab will perform an ajax request the first time the tab is requested.
-
TAB_MODE_CLIENT
public static final WTabSet.TabMode TAB_MODE_CLIENT
A tab mode where tab content is always rendered, and invoking the tab only results in a client-side switch.
-
TAB_MODE_DYNAMIC
public static final WTabSet.TabMode TAB_MODE_DYNAMIC
A tab mode where invoking the tab will perform an ajax request every time the tab is requested.
-
TAB_MODE_EAGER
public static final WTabSet.TabMode TAB_MODE_EAGER
A tab mode where invoking the tab will perform an ajax request immediately after the page is loaded.
-
-
Constructor Detail
-
WTabSet
public WTabSet()
Creates a WTabSet with the tabs positioned on the top.
-
WTabSet
public WTabSet(WTabSet.TabSetType type)
Creates a WTabSet of the given type.- Parameters:
type
- the tab set type.
-
-
Method Detail
-
getType
public WTabSet.TabSetType getType()
- Returns:
- the tab set type.
-
setMargin
public void setMargin(Margin margin)
Set the margin for the component, or null for no margin.- Specified by:
setMargin
in interfaceMarginable
- Parameters:
margin
- the margin for the component
-
getMargin
public Margin getMargin()
Get the margin for the component, or null if not set.- Specified by:
getMargin
in interfaceMarginable
- Returns:
- the margin for the component, or null if not set
-
setContentHeight
public void setContentHeight(String contentHeight)
Sets the content height of the tab set. This is primarily used for tab sets where the tabs are positioned on the left or right, to limit the height of the tab set.- Parameters:
contentHeight
- the content height, measured in a valid CSS unit, e.g. "10em".
-
getContentHeight
public String getContentHeight()
- Returns:
- the tab set's content height, if set, otherwise null.
-
addTab
public WTab addTab(WComponent content, String tabName)
Adds a tab to the tab set with a TabMode of LAZY.- Parameters:
content
- the tab set content.tabName
- the tab name.- Returns:
- the tab which was added to the tab set.
-
addTab
public WTab addTab(WComponent content, WDecoratedLabel label)
Adds a LAZY mode tab to the tab set.- Parameters:
content
- the tab set content.label
- the tab's label, which can contain rich content (images or other components).- Returns:
- the tab which was added to the tab set.
-
addTab
public WTab addTab(WComponent content, String tabName, WTabSet.TabMode mode)
Adds a tab to the tab set.- Parameters:
content
- the tab set content.tabName
- the tab name.mode
- the tab mode.- Returns:
- the tab which was added to the tab set.
-
addTab
public WTab addTab(WComponent content, String tabName, WTabSet.TabMode mode, char accessKey)
Adds a tab to the tab set.- Parameters:
content
- the tab set content.tabName
- the tab name.mode
- the tab mode.accessKey
- the access key used to activate the tab.- Returns:
- the tab which was added to the tab set.
-
addTab
public WTab addTab(WComponent content, String tabName, char accessKey)
Adds a LAZY tab with a given access key to the tab set.- Parameters:
content
- the tab set content.tabName
- the tab name.accessKey
- the access key used to activate the tab.- Returns:
- the tab which was added to the tab set.
-
addTab
public WTab addTab(WComponent content, WDecoratedLabel label, WTabSet.TabMode mode)
Adds a tab to the tab set.- Parameters:
content
- the tab set content.label
- the tab's label, which can contain rich content (images or other components).mode
- the tab mode.- Returns:
- the tab which was added to the tab set.
-
addTab
public WTab addTab(WComponent content, WDecoratedLabel label, WTabSet.TabMode mode, char accessKey)
Adds a tab to the tab set.- Parameters:
content
- the tab set content.label
- the tab's label, which can contain rich content (images or other components).mode
- the tab mode.accessKey
- the access key used to activate the tab.- Returns:
- the tab which was added to the tab set.
-
addTab
public WTab addTab(WComponent content, WDecoratedLabel label, char accessKey)
Adds a LAZY tab with a given access key to the tab set.- Parameters:
content
- the tab set content.label
- the tab's label, which can contain rich content (images or other components).accessKey
- the access key used to activate the tab.- Returns:
- the tab which was added to the tab set.
-
addSeparator
@Deprecated public void addSeparator()
Deprecated.separators are not available to tabsets as it does not conform with a11y requirements.Adds a separator to the tab set.
-
add
@Deprecated public void add(WTab tab)
Deprecated.useaddTab(WComponent, String)
or overloaded version.Adds a tab to the tab set.- Parameters:
tab
- the tab to add.
-
addTab
protected WTab addTab(WTab tab)
Adds aWTab
to the tab set.- Parameters:
tab
- the tab to add.- Returns:
- the tab which was added to the tab set.
-
add
@Deprecated public void add(WTabGroup group)
Deprecated.Do not use TabGroupsAdds a tab group to the tab set.- Parameters:
group
- the group to add.
-
add
@Deprecated public void add(WSeparator separator)
Deprecated.separators are not available to tabsets as it does not conform with a11y requirements.Adds a separator to the tab set.- Parameters:
separator
- the separator to add.
-
getTotalTabs
public int getTotalTabs()
Retrieves the total number of tabs in this tab set.- Returns:
- the number of tabs in this tab set.
-
getActiveIndex
public int getActiveIndex()
Returns the default active index. Note that some tab sets support multiple active tabs, seegetActiveIndices()
.If there are no active tabs, then the first tab will be returned as the default tab.
- Returns:
- the default active tab index.
-
getActiveIndices
public List<Integer> getActiveIndices()
Returns the active indices (as seen by the given context/session).- Returns:
- the active tab indices (may be an empty list).
-
getActiveTab
public WTab getActiveTab()
Returns the active tab (as seen by the given context/session). Note that some tab sets support multiple active tabs, seegetActiveTabs()
.- Returns:
- the active tab (as seen by the given context/session).
-
getActiveTabs
public List<WTab> getActiveTabs()
Returns the active tabs (as seen by the given context/session).- Returns:
- the active tabs (as seen by the given context/session).
-
setActiveIndex
public void setActiveIndex(int activeIndex)
Sets the active index(as seen by the given context/session).- Parameters:
activeIndex
- the index of the tab to mark as the active one.
-
setActiveIndices
public void setActiveIndices(int[] indices)
Sets the active tab indices (as seen by the given context/session).- Parameters:
indices
- the tab indices to set
-
setActiveTab
public void setActiveTab(WComponent content)
Sets the active tab using tab content.- Parameters:
content
- the active tab's content.
-
setActiveTab
public void setActiveTab(WTab tab)
Sets the active tab.- Parameters:
tab
- the active tab.
-
setTabVisible
public void setTabVisible(int idx, boolean visible)
Sets the visibility of the tab at the given index.- Parameters:
idx
- the index of the WTab to get.visible
- true to set the tab visible, false to set invisible.
-
setTabVisible
public void setTabVisible(WComponent tabContent, boolean visible)
Sets the visibility of the tab which holds the given content.- Parameters:
tabContent
- the tab content.visible
- true to set the tab visible, false to set invisible.
-
setTabVisible
public void setTabVisible(WTab tab, boolean visible)
Sets the visibility of the tab.- Parameters:
tab
- the tab.visible
- true to set the tab visible, false to set invisible.
-
isTabVisible
public boolean isTabVisible(int idx)
Indicates whether the tab at the given index is visible.- Parameters:
idx
- the index of the WTab to test.- Returns:
- true if the tab at the given index is visible, false if it is invisible.
-
isTabVisible
public boolean isTabVisible(WComponent tabContent)
Indicates whether the tab which holds the given content is visible.- Parameters:
tabContent
- the tab content.- Returns:
- true if the tab at the given index is visible, false if it is invisible.
-
isTabVisible
public boolean isTabVisible(WTab tab)
Indicates whether the tab which holds the given content is visible.- Parameters:
tab
- the tab content.- Returns:
- true if the tab at the given index is visible, false if it is invisible.
-
isActive
public boolean isActive(WComponent tab)
Indicates whether the tab is active (selected).- Parameters:
tab
- the WTab to check.- Returns:
- true if the tab is active, false otherwise.
-
isActive
public boolean isActive(WTab tab)
Indicates whether the tab is active (selected).- Parameters:
tab
- the WTab to check.- Returns:
- true if the tab is active, false otherwise.
-
getTabIndex
public int getTabIndex(WComponent content)
Retrieves the tab index for the given tab content.- Parameters:
content
- the tab content- Returns:
- the tab index, or -1 if the content is not in a tab in this tab set.
-
getTabIndex
public int getTabIndex(WTab tab)
Retrieves the tab index for the given tab.- Parameters:
tab
- the tab- Returns:
- the tab index, or -1 if the tab is not in this tab set.
-
getTab
public WTab getTab(int index)
Returns the tab at the given index. Bounds checking is not performed.- Parameters:
index
- the tab index.- Returns:
- the tab at the selected index.
-
handleRequest
public void handleRequest(Request request)
Override handleRequest in order to perform processing specific to this component.- Specified by:
handleRequest
in interfaceWComponent
- Overrides:
handleRequest
in classAbstractWComponent
- Parameters:
request
- the request being responded to.
-
isDisabled
public boolean isDisabled()
Indicates whether the WTabSet is disabled in the given context.- Specified by:
isDisabled
in interfaceDisableable
- Returns:
- true if the input is disabled, otherwise false.
-
setDisabled
public void setDisabled(boolean disabled)
Sets whether the WTabSet is disabled.- Specified by:
setDisabled
in interfaceDisableable
- Parameters:
disabled
- if true, the input is disabled. If false, it is enabled.
-
remove
public void remove(WComponent child)
-
setActionOnChange
@Deprecated public void setActionOnChange(Action action)
Deprecated.an action on changing tab is a side-effect and should not be implemented.Sets the action to be executed when the tab selection of thistabset
changes.- Parameters:
action
- the action to execute
-
getActionOnChange
@Deprecated public Action getActionOnChange()
Deprecated.an action on changing tab is a side-effect and should not be implemented.Gets the action that is executed when the tab selection of thistabset
changes.- Returns:
- The
action
associated with thistabset
.
-
setShowHeadOnly
@Deprecated public void setShowHeadOnly(boolean showHeadOnly)
Deprecated.1.4.7 an irrelevant hangover from a bad design decision - never implemented.Sets whether only the "head" portion of a tab's decorated label should be visible. At present, this only has a visible effect onWTabSet.TabSetType.APPLICATION
tab sets.- Parameters:
showHeadOnly
- true if only the "head" part of the tab label should be shown.
-
isShowHeadOnly
@Deprecated public boolean isShowHeadOnly()
Deprecated.1.4.7 an irrelevant hangover from a bad design decision - never implemented.Indicates whether only the "head" portion of a tab's decorated label should be visible. At present, this only has a visible effect onWTabSet.TabSetType.APPLICATION
tab sets.- Returns:
- true if only the "head" part of the tab label should be shown.
-
setSingle
public void setSingle(boolean single)
- Parameters:
single
- true if only one tab should be open at a time for an accordion tabset
-
isSingle
public boolean isSingle()
- Returns:
- true if only one tab should be open at a time for an accordion tabset
-
getGroupName
public String getGroupName()
The "collapsible" group name that this tabset belongs to.- Returns:
- the collapsible group name
-
setGroup
public void setGroup(CollapsibleGroup group)
Set theCollapsibleGroup
that this component belongs to. This will enable aWCollapsibleToggle
component to target the tabset as part of the group.- Parameters:
group
- the group to set
-
toString
public String toString()
Description copied from class:AbstractWComponent
Creates a String representation of this component; usually for debugging purposes.- Overrides:
toString
in classAbstractWComponent
- Returns:
- a String representation of this component, for debugging purposes.
-
newComponentModel
protected WTabSet.TabSetModel newComponentModel()
Creates a new Component model.- Overrides:
newComponentModel
in classAbstractWComponent
- Returns:
- a new TabSetModel.
-
getComponentModel
protected WTabSet.TabSetModel 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 WTabSet.TabSetModel 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
-
-