Class WSingleSelect
-
- All Implemented Interfaces:
AjaxTarget
,AjaxTrigger
,Autocompleteable
,AutocompleteableDate
,AutocompleteableEmail
,AutocompleteableNumeric
,AutocompleteablePassword
,AutocompleteablePhone
,AutocompleteableText
,AutocompleteableURL
,BeanAware
,BeanBound
,BeanProviderBound
,DataBound
,Diagnosable
,Disableable
,Input
,Labelable
,Mandatable
,SubordinateTarget
,SubordinateTrigger
,WComponent
,WebComponent
,Serializable
public class WSingleSelect extends AbstractWSingleSelectList implements AjaxTrigger, AjaxTarget, SubordinateTrigger, SubordinateTarget, AutocompleteableText
The WSingleSelect input component allows the user to select one option from a list. The list of options that can be selected are supplied at construction time as a parameter in the constructor or via the
AbstractWSelectList.setOptions(List)
method. The list of options are java objects that are rendered using their toString() by default.Use the
getSelected
method to determine which of the list of options was chosen by the user. Note that getSelected returns one of the object instances supplied in the original list of options.- Since:
- 1.0.0
- Author:
- Jonathan Austin, Mark Reeves
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
WSingleSelect.SingleSelectModel
Holds the extrinsic state information of the component.-
Nested classes/interfaces inherited from class com.github.bordertech.wcomponents.AbstractWSelectList
AbstractWSelectList.SelectionModel
-
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 class com.github.bordertech.wcomponents.AbstractWSingleSelectList
EMPTY
-
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 WSingleSelect()
Creates an empty WSingleSelect.WSingleSelect(Object table)
Creates a WSingleSelect with the options provided by the given table.WSingleSelect(Object[] options)
Creates a WSingleSelect containing the specified options.WSingleSelect(List options)
Creates a WSingleSelect containing the specified options.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAutocompleteSection(String sectionName)
Pre-pend anautocomplete
section to the value of anautocomplete
attribute for the current field.void
clearAutocomplete()
Clear theautocomplete
attribute.String
getAutocomplete()
protected WSingleSelect.SingleSelectModel
getComponentModel()
Returns the effective component model for this component.protected WSingleSelect.SingleSelectModel
getOrCreateComponentModel()
Retrieves the model for this component so that it can be modified.int
getRows()
protected WSingleSelect.SingleSelectModel
newComponentModel()
Creates a new Component model.void
setAddressAutocomplete(AddressType addressType, AddressPart addressPart)
Set values for theautocomplete
attribute applicable to an address or part thereof.void
setAutocomplete(AutocompleteSegment value)
Setautocomplete
attribute value for a field based on a segment name.void
setAutocomplete(DateType value)
Set theautocomplete
s attribute for a type of date input.void
setAutocomplete(Email value)
Set theautocomplete
attribute to a specific "email" value.void
setAutocomplete(Numeric value)
Set the autocomplete attribute for a number field for a given numeric auto-fill value.void
setAutocomplete(Password value)
Set theautocomplete
attribute of a password field to a given password auto-fill hint type.void
setAutocomplete(Telephone phone, PhoneFormat phoneType)
Set theautocomplete
attribute to an appropriate value for a particular type of phone number, in either of a full or local format.void
setAutocomplete(Url value)
Set theautocomplete
attribute to a specific URL auto-fill type: "url", "impp" or "photo".void
setAutocompleteOff()
Turnautocomplete
off for the current field.void
setPhoneSegmentAutocomplete(PhoneFormat phoneType, PhonePart phoneSegment)
Set theautocomplete
attribute value relevant for a specified telephone number type and segment.void
setRows(int rows)
Sets the maximum number of rows that are visible in the list at any one time.-
Methods inherited from class com.github.bordertech.wcomponents.AbstractWSingleSelectList
doHandleInvalidOption, doHandleRequest, getData, getNewSelection, getRequestValue, getSelected, getValue, hasSelection, preparePaintComponent, setData, setSelected
-
Methods inherited from class com.github.bordertech.wcomponents.AbstractWSelectList
getAjaxTarget, getCode, getDesc, getDescEncode, getListCacheKey, getLookupTable, getOptionIndex, getOptions, isAjax, isAllowNoSelection, isEditable, isPresent, isSelectionOrderable, isSubmitOnChange, optionToCode, optionToCode, optionToString, setAjaxTarget, setDescEncode, setEditable, setLookupTable, setOptions, setOptions, setSubmitOnChange
-
Methods inherited from class com.github.bordertech.wcomponents.AbstractInput
addValidator, beforeHandleRequest, createMandatoryDiagnostic, doHandleChanged, getActionCommand, getActionObject, getActionOnChange, getDefaultSubmitButton, getDiagnostics, getValidators, getValueAsString, handleRequest, isChangedInLastRequest, isCurrentAjaxTrigger, isDisabled, isEmpty, isMandatory, isReadOnly, setActionObject, setActionOnChange, setChangedInLastRequest, setDefaultSubmitButton, 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, isBeanInScratchMap, isChanged, isSearchAncestors, isUseRequestScopeScratchMap, removeBeanFromScratchMap, resetData, setBean, setBeanId, setBeanProperty, setBeanProvider, 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, 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.autocomplete.Autocompleteable
isAutocompleteOff
-
Methods inherited from interface com.github.bordertech.wcomponents.autocomplete.AutocompleteableDate
setBirthdayAutocomplete
-
Methods inherited from interface com.github.bordertech.wcomponents.autocomplete.AutocompleteableEmail
setEmailAutocomplete
-
Methods inherited from interface com.github.bordertech.wcomponents.autocomplete.AutocompleteablePhone
setFullPhoneAutocomplete, setFullPhoneAutocomplete, setLocalPhoneAutocomplete, setLocalPhoneAutocomplete
-
Methods inherited from interface com.github.bordertech.wcomponents.autocomplete.AutocompleteableURL
setUrlAutocomplete
-
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
-
WSingleSelect
public WSingleSelect()
Creates an empty WSingleSelect.
-
WSingleSelect
public WSingleSelect(Object[] options)
Creates a WSingleSelect containing the specified options.- Parameters:
options
- the options to display.
-
WSingleSelect
public WSingleSelect(List options)
Creates a WSingleSelect containing the specified options.- Parameters:
options
- the options to display.
-
WSingleSelect
public WSingleSelect(Object table)
Creates a WSingleSelect with the options provided by the given table.- Parameters:
table
- the table to obtain the list's options from.
-
-
Method Detail
-
setRows
public void setRows(int rows)
Sets the maximum number of rows that are visible in the list at any one time. If the number of rows is less than two, then the default number of rows will be displayed.- Parameters:
rows
- the number of rows to display.
-
getRows
public int getRows()
- Returns:
- the number of rows to display in the list.
-
getAutocomplete
public String getAutocomplete()
- Specified by:
getAutocomplete
in interfaceAutocompleteable
- Returns:
- the value of the
autocomplete
attribute applied to the current field.
-
setAutocompleteOff
public void setAutocompleteOff()
Description copied from interface:Autocompleteable
Turnautocomplete
off for the current field.- Specified by:
setAutocompleteOff
in interfaceAutocompleteable
-
addAutocompleteSection
public void addAutocompleteSection(String sectionName)
Description copied from interface:Autocompleteable
Pre-pend anautocomplete
section to the value of anautocomplete
attribute for the current field.- Specified by:
addAutocompleteSection
in interfaceAutocompleteable
- Parameters:
sectionName
- the name of the section being the part which would replace the asterisk in the formsection-*
-
clearAutocomplete
public void clearAutocomplete()
Description copied from interface:Autocompleteable
Clear theautocomplete
attribute.- Specified by:
clearAutocomplete
in interfaceAutocompleteable
-
setAutocomplete
public void setAutocomplete(DateType value)
Description copied from interface:AutocompleteableDate
Set theautocomplete
s attribute for a type of date input.- Specified by:
setAutocomplete
in interfaceAutocompleteableDate
- Parameters:
value
- the type of date to auto-fill, currently only "bday" is supported.
-
setAutocomplete
public void setAutocomplete(Email value)
Description copied from interface:AutocompleteableEmail
Set theautocomplete
attribute to a specific "email" value. Currently only value "email" is supported.- Specified by:
setAutocomplete
in interfaceAutocompleteableEmail
- Parameters:
value
- the auto-fill hint value
-
setAutocomplete
public void setAutocomplete(Numeric value)
Description copied from interface:AutocompleteableNumeric
Set the autocomplete attribute for a number field for a given numeric auto-fill value.- Specified by:
setAutocomplete
in interfaceAutocompleteableNumeric
- Parameters:
value
- the type of number for auto-fill
-
setAutocomplete
public void setAutocomplete(Password value)
Description copied from interface:AutocompleteablePassword
Set theautocomplete
attribute of a password field to a given password auto-fill hint type.- Specified by:
setAutocomplete
in interfaceAutocompleteablePassword
- Parameters:
value
- the type of password field to auto-fill
-
setAutocomplete
public void setAutocomplete(Url value)
Description copied from interface:AutocompleteableURL
Set theautocomplete
attribute to a specific URL auto-fill type: "url", "impp" or "photo".- Specified by:
setAutocomplete
in interfaceAutocompleteableURL
- Parameters:
value
- the auto-fill hint value
-
setAutocomplete
public void setAutocomplete(AutocompleteSegment value)
Description copied from interface:AutocompleteableText
Setautocomplete
attribute value for a field based on a segment name.- Specified by:
setAutocomplete
in interfaceAutocompleteableText
- Parameters:
value
- the auto-fill mnemonic
-
setAutocomplete
public void setAutocomplete(Telephone phone, PhoneFormat phoneType)
Description copied from interface:AutocompleteablePhone
Set theautocomplete
attribute to an appropriate value for a particular type of phone number, in either of a full or local format.- Specified by:
setAutocomplete
in interfaceAutocompleteablePhone
- Parameters:
phone
- the telephone auto-fill variant, being full (including international prefix) or local (without international prefix)phoneType
- the type of phone to which the number belongs, for example "mobile" or "fax"
-
setPhoneSegmentAutocomplete
public void setPhoneSegmentAutocomplete(PhoneFormat phoneType, PhonePart phoneSegment)
Description copied from interface:AutocompleteableText
Set theautocomplete
attribute value relevant for a specified telephone number type and segment.- Specified by:
setPhoneSegmentAutocomplete
in interfaceAutocompleteableText
- Parameters:
phoneType
- the type of phone numberphoneSegment
- the phone number segment
-
setAddressAutocomplete
public void setAddressAutocomplete(AddressType addressType, AddressPart addressPart)
Description copied from interface:AutocompleteableText
Set values for theautocomplete
attribute applicable to an address or part thereof.- Specified by:
setAddressAutocomplete
in interfaceAutocompleteableText
- Parameters:
addressType
- the type of address being auto-filledaddressPart
- the address segment for the field
-
newComponentModel
protected WSingleSelect.SingleSelectModel newComponentModel()
Creates a new Component model.- Overrides:
newComponentModel
in classAbstractWSelectList
- Returns:
- a new SingleSelectModel.
-
getComponentModel
protected WSingleSelect.SingleSelectModel getComponentModel()
Description copied from class:AbstractWSelectList
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 classAbstractWSelectList
- Returns:
- the effective component model
-
getOrCreateComponentModel
protected WSingleSelect.SingleSelectModel getOrCreateComponentModel()
Description copied from class:AbstractWSelectList
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 classAbstractWSelectList
- Returns:
- the model for this component
-
-