Class WCollapsible
- java.lang.Object
-
- com.github.bordertech.wcomponents.AbstractWComponent
-
- com.github.bordertech.wcomponents.AbstractContainer
-
- com.github.bordertech.wcomponents.AbstractNamingContextContainer
-
- com.github.bordertech.wcomponents.WCollapsible
-
- All Implemented Interfaces:
AjaxTarget,Container,Marginable,NamingContextable,SubordinateTarget,WComponent,WebComponent,Serializable
public class WCollapsible extends AbstractNamingContextContainer implements AjaxTarget, SubordinateTarget, Marginable
The WCollapsible component enables a given component to be expanded/collapsed (shown/hidden) via clicking on the collapsible's header section. When a user clicks the heading, the visibility of the collapsible's content is toggled.
Various
modes of operationare supported, which allow developers to tune performance by only loading content when it is needed.- Author:
- Martin Shevchenko
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWCollapsible.CollapsibleModeThe available types of collapsible mode.static classWCollapsible.CollapsibleModelHolds the extrinsic state information of a WCollapsible.-
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 WCollapsible(WComponent content, WDecoratedLabel label)Creates a WCollapsible with the given content and heading.WCollapsible(WComponent content, WDecoratedLabel label, WCollapsible.CollapsibleMode mode)Creates a WCollapsible with the given content and heading.WCollapsible(WComponent content, WDecoratedLabel label, WCollapsible.CollapsibleMode mode, CollapsibleGroup group)Creates a WCollapsible with the given content, heading and group.WCollapsible(WComponent content, String heading)Creates a WCollapsible with the given content and heading.WCollapsible(WComponent content, String heading, WCollapsible.CollapsibleMode mode)Creates a WCollapsible with the given content and heading.WCollapsible(WComponent content, String heading, WCollapsible.CollapsibleMode mode, CollapsibleGroup group)Creates a WCollapsible with the given content, heading and group.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected WCollapsible.CollapsibleModelgetComponentModel()Returns the effective component model for this component.WComponentgetContent()WDecoratedLabelgetDecoratedLabel()StringgetGroupName()The group name that this collapsible component belongs to.StringgetHeading()Deprecated.usegetDecoratedLabel().getText()HeadingLevelgetHeadingLevel()MargingetMargin()Get the margin for the component, or null if not set.WCollapsible.CollapsibleModegetMode()protected WCollapsible.CollapsibleModelgetOrCreateComponentModel()Retrieves the model for this component so that it can be modified.voidhandleRequest(Request request)Override handleRequest to perform processing necessary for this component.booleanisCollapsed()Indicates whether the collapsible is collapsed in the given context.protected WCollapsible.CollapsibleModelnewComponentModel()Creates a new component model appropriate for this component.protected voidpreparePaintComponent(Request request)Override preparePaintComponent in order to toggle the visibility of the content, or to register the appropriate ajax operation.voidsetCollapsed(boolean collapsed)Sets whether the collapsible is collapsed in the given context.voidsetGroup(CollapsibleGroup group)Set theCollapsibleGroupthat this component belongs to.voidsetHeading(String heading)Deprecated.usegetDecoratedLabel().setText(String)voidsetHeadingLevel(HeadingLevel headingLevel)voidsetMargin(Margin margin)Set the margin for the component, or null for no margin.voidsetMode(WCollapsible.CollapsibleMode mode)Sets this WCollapsible's mode of operation.StringtoString()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, 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
-
-
-
-
Constructor Detail
-
WCollapsible
public WCollapsible(WComponent content, String heading)
Creates a WCollapsible with the given content and heading.- Parameters:
content- the content to display inside the collapsible.heading- the collapsible's heading.
-
WCollapsible
public WCollapsible(WComponent content, WDecoratedLabel label)
Creates a WCollapsible with the given content and heading.- Parameters:
content- the content to display inside the collapsible.label- the collapsible's heading.
-
WCollapsible
public WCollapsible(WComponent content, String heading, WCollapsible.CollapsibleMode mode)
Creates a WCollapsible with the given content and heading.- Parameters:
content- the content to display inside the collapsible.heading- the collapsible's heading.mode- the mode of the collapsible
-
WCollapsible
public WCollapsible(WComponent content, WDecoratedLabel label, WCollapsible.CollapsibleMode mode)
Creates a WCollapsible with the given content and heading.- Parameters:
content- the content to display inside the collapsible.label- the collapsible's heading.mode- the mode of the collapsible
-
WCollapsible
public WCollapsible(WComponent content, String heading, WCollapsible.CollapsibleMode mode, CollapsibleGroup group)
Creates a WCollapsible with the given content, heading and group.- Parameters:
content- the content to display inside the collapsible.heading- the collapsible's heading.mode- the mode of the collapsiblegroup- theCollapsibleGroupthat this collapsible belongs to.
-
WCollapsible
public WCollapsible(WComponent content, WDecoratedLabel label, WCollapsible.CollapsibleMode mode, CollapsibleGroup group)
Creates a WCollapsible with the given content, heading and group.- Parameters:
content- the content to display inside the collapsible.label- the collapsible's heading.mode- the mode of the collapsiblegroup- theCollapsibleGroupthat this collapsible belongs to.
-
-
Method Detail
-
getMode
public WCollapsible.CollapsibleMode getMode()
- Returns:
- this WCollapsible's mode of operation
-
setMode
public void setMode(WCollapsible.CollapsibleMode mode)
Sets this WCollapsible's mode of operation. CollapsibleMode.SERVER is mapped to CollapsibleMode.DYNAMIC in order to prevent an a11y issue as per #694.- Parameters:
mode- the mode of operation.
-
setMargin
public void setMargin(Margin margin)
Set the margin for the component, or null for no margin.- Specified by:
setMarginin 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:
getMarginin interfaceMarginable- Returns:
- the margin for the component, or null if not set
-
isCollapsed
public boolean isCollapsed()
Indicates whether the collapsible is collapsed in the given context.- Returns:
- true if the collapsible is collapsed for the given user, false if expanded.
-
setCollapsed
public void setCollapsed(boolean collapsed)
Sets whether the collapsible is collapsed in the given context.- Parameters:
collapsed- true if the collapsible is to be collapsed for the given user, false if expanded.
-
getContent
public WComponent getContent()
- Returns:
- the content of this collapsible
-
getDecoratedLabel
public WDecoratedLabel getDecoratedLabel()
- Returns:
- the decorated label that is used to render the collapsible heading.
-
getHeading
@Deprecated public String getHeading()
Deprecated.usegetDecoratedLabel().getText()Retrieves the collapsible's default heading.- Returns:
- the heading text.
-
setHeading
@Deprecated public void setHeading(String heading)
Deprecated.usegetDecoratedLabel().setText(String)Sets the collapsible's heading for the given context.- Parameters:
heading- the heading text to set.
-
getGroupName
public String getGroupName()
The group name that this collapsible component belongs to. If it is not part of a group then the name defaults toWComponent.getName().- Returns:
- the collapsible group name
-
setGroup
public void setGroup(CollapsibleGroup group)
Set theCollapsibleGroupthat this component belongs to. This will enable aWCollapsibleTogglecomponent to target the group.- Parameters:
group- the group to set
-
getHeadingLevel
public HeadingLevel getHeadingLevel()
- Returns:
- the collapsible's heading level
-
setHeadingLevel
public void setHeadingLevel(HeadingLevel headingLevel)
- Parameters:
headingLevel- the collapsible's heading level
-
handleRequest
public void handleRequest(Request request)
Override handleRequest to perform processing necessary for this component. This is used to handle the server-side collapsible mode and to synchronise with the client-side state for the other modes.- Specified by:
handleRequestin interfaceWComponent- Overrides:
handleRequestin classAbstractWComponent- Parameters:
request- the request being responded to.
-
preparePaintComponent
protected void preparePaintComponent(Request request)
Override preparePaintComponent in order to toggle the visibility of the content, or to register the appropriate ajax operation.- Overrides:
preparePaintComponentin classAbstractWComponent- Parameters:
request- the request being responded to
-
toString
public String toString()
Description copied from class:AbstractWComponentCreates a String representation of this component; usually for debugging purposes.- Overrides:
toStringin classAbstractWComponent- Returns:
- a String representation of this component, for debugging purposes.
-
newComponentModel
protected WCollapsible.CollapsibleModel newComponentModel()
Creates a new component model appropriate for this component.- Overrides:
newComponentModelin classAbstractWComponent- Returns:
- a new CollapsibleModel.
-
getComponentModel
protected WCollapsible.CollapsibleModel 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:
getComponentModelin classAbstractWComponent- Returns:
- the effective component model
-
getOrCreateComponentModel
protected WCollapsible.CollapsibleModel 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:
getOrCreateComponentModelin classAbstractWComponent- Returns:
- the model for this component
-
-