Class WToggleButton
- java.lang.Object
-
- com.github.bordertech.wcomponents.AbstractWComponent
-
- com.github.bordertech.wcomponents.WBeanComponent
-
- com.github.bordertech.wcomponents.AbstractInput
-
- com.github.bordertech.wcomponents.WCheckBox
-
- com.github.bordertech.wcomponents.WToggleButton
-
- All Implemented Interfaces:
AjaxTarget,AjaxTrigger,BeanAware,BeanBound,BeanProviderBound,DataBound,Diagnosable,Disableable,Input,Labelable,Mandatable,SelectionToggleable,SubordinateTarget,SubordinateTrigger,WComponent,WebComponent,Serializable
public class WToggleButton extends WCheckBox
A selectable component with a button-like appearance.- Author:
- Mark Reeves
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWToggleButton.ToggleButtonModelHolds state information for the toggle button.-
Nested classes/interfaces inherited from class com.github.bordertech.wcomponents.WCheckBox
WCheckBox.CheckBoxModel
-
Nested classes/interfaces inherited from class com.github.bordertech.wcomponents.AbstractInput
AbstractInput.InputModel
-
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 WToggleButton()Create a default WToggleButton.WToggleButton(boolean selected)Create a WToggleButton in a given selected state.WToggleButton(String text)Create a WToggleButton with specific text.WToggleButton(String text, boolean selected)Create a WToggleButton with specified text and selected state.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected WToggleButton.ToggleButtonModelgetComponentModel()Returns the effective component model for this component.WButtongetDefaultSubmitButton()protected WToggleButton.ToggleButtonModelgetOrCreateComponentModel()Retrieves the model for this component so that it can be modified.StringgetText()booleanisMandatory()A WToggleButton cannot be mandatory as a mandatory toggle button is one which must be set into a selected state and if a control must be set into a selected state it is not a selection control.booleanisSubmitOnChange()Indicates whether the form should be submitted when the checkbox is checked/unchecked.protected WToggleButton.ToggleButtonModelnewComponentModel()Creates a new Component model.voidsetDefaultSubmitButton(WButton defaultSubmitButton)Do not allow defaultSubmitButton on a WToggleButton.voidsetSubmitOnChange(boolean submitOnChange)Must not set submitOnChange on a WToggleButton.voidsetText(String text)Sets the button text.-
Methods inherited from class com.github.bordertech.wcomponents.WCheckBox
doHandleRequest, getActionCommand, getGroup, getRequestValue, getValue, getValueAsString, isSelected, setGroup, setSelected, toggleSelection
-
Methods inherited from class com.github.bordertech.wcomponents.AbstractInput
addValidator, beforeHandleRequest, createMandatoryDiagnostic, doHandleChanged, getActionObject, getActionOnChange, getDiagnostics, getValidators, handleRequest, isChangedInLastRequest, isCurrentAjaxTrigger, isDisabled, isEmpty, isPresent, isReadOnly, setActionObject, setActionOnChange, setChangedInLastRequest, setDisabled, setMandatory, setMandatory, setReadOnly, showErrorIndicatorsForComponent, showIndicatorsForComponent, showWarningIndicatorsForComponent, toString, validateComponent
-
Methods inherited from class com.github.bordertech.wcomponents.WBeanComponent
addBeanToScratchMap, doUpdateBeanValue, getBean, getBeanFromScratchMap, getBeanId, getBeanProperty, getBeanProvider, getBeanScratchMap, getBeanValue, getData, isBeanInScratchMap, isChanged, isSearchAncestors, isUseRequestScopeScratchMap, removeBeanFromScratchMap, resetData, setBean, setBeanId, setBeanProperty, setBeanProvider, setData, setSearchAncestors, updateBeanValue
-
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, showWarningIndicators, tidyUpUIContext, tidyUpUIContextForTree, validate, 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.BeanAware
getBean, getBeanProperty, getBeanValue, setBeanProperty
-
Methods inherited from interface com.github.bordertech.wcomponents.BeanBound
isSearchAncestors, setBean
-
Methods inherited from interface com.github.bordertech.wcomponents.BeanProviderBound
getBeanId, setBeanId, setBeanProvider
-
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, handleRequest, 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
-
WToggleButton
public WToggleButton()
Create a default WToggleButton.
-
WToggleButton
public WToggleButton(boolean selected)
Create a WToggleButton in a given selected state.- Parameters:
selected- the selected state
-
WToggleButton
public WToggleButton(String text)
Create a WToggleButton with specific text.- Parameters:
text- the text to show on the toggle button
-
WToggleButton
public WToggleButton(String text, boolean selected)
Create a WToggleButton with specified text and selected state.- Parameters:
selected- thee selected state of the toggle button wheretrueis selectedtext- the text to show on the toggle button
-
-
Method Detail
-
setText
public final void setText(String text)
Sets the button text.- Parameters:
text- the button text, usingMessageFormatsyntax
-
getText
public String getText()
- Returns:
- the text to show on the toggle button
-
setDefaultSubmitButton
public void setDefaultSubmitButton(WButton defaultSubmitButton)
Do not allow defaultSubmitButton on a WToggleButton.- Specified by:
setDefaultSubmitButtonin interfaceInput- Overrides:
setDefaultSubmitButtonin classAbstractInput- Parameters:
defaultSubmitButton- not used
-
getDefaultSubmitButton
public WButton getDefaultSubmitButton()
Description copied from class:AbstractInput- Specified by:
getDefaultSubmitButtonin interfaceInput- Overrides:
getDefaultSubmitButtonin classAbstractInput- Returns:
- null as there cannot be a defaultSubmitButton on a WToggleButton.
-
isMandatory
public boolean isMandatory()
A WToggleButton cannot be mandatory as a mandatory toggle button is one which must be set into a selected state and if a control must be set into a selected state it is not a selection control.- Specified by:
isMandatoryin interfaceMandatable- Overrides:
isMandatoryin classAbstractInput- Returns:
- false
-
setSubmitOnChange
public void setSubmitOnChange(boolean submitOnChange)
Must not set submitOnChange on a WToggleButton. If you need a button which submits the form useWButton.- Overrides:
setSubmitOnChangein classWCheckBox- Parameters:
submitOnChange- not used
-
isSubmitOnChange
public boolean isSubmitOnChange()
Description copied from class:WCheckBoxIndicates whether the form should be submitted when the checkbox is checked/unchecked.- Overrides:
isSubmitOnChangein classWCheckBox- Returns:
- false as WToggleButton cannot have submitOnChange: that would be a WButton
-
newComponentModel
protected WToggleButton.ToggleButtonModel newComponentModel()
Creates a new Component model.- Overrides:
newComponentModelin classWCheckBox- Returns:
- a new ToggleButtonModel.
-
getComponentModel
protected WToggleButton.ToggleButtonModel 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 classWCheckBox- Returns:
- the effective component model
-
getOrCreateComponentModel
protected WToggleButton.ToggleButtonModel 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 classWCheckBox- Returns:
- the model for this component
-
-