Package com.helger.html.hc.html.forms
Class AbstractHCSelect<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>
- java.lang.Object
-
- com.helger.html.hc.impl.AbstractHCNode
-
- com.helger.html.hc.html.AbstractHCElement<IMPLTYPE>
-
- com.helger.html.hc.html.forms.AbstractHCControl<IMPLTYPE>
-
- com.helger.html.hc.html.forms.AbstractHCSelect<IMPLTYPE>
-
- Type Parameters:
IMPLTYPE- the implementation type
- All Implemented Interfaces:
com.helger.commons.hierarchy.IHasChildren<IHCNode>,com.helger.commons.hierarchy.IHasChildrenRecursive<IHCNode>,com.helger.commons.hierarchy.IHasChildrenSorted<IHCNode>,com.helger.commons.traits.IGenericImplTrait<IMPLTYPE>,IHCControl<IMPLTYPE>,IHCHasFocus<IMPLTYPE>,IHCSelect<IMPLTYPE>,IHCElement<IMPLTYPE>,IHCHasCSSClasses<IMPLTYPE>,IHCHasCSSStyles<IMPLTYPE>,IHCHasState<IMPLTYPE>,IHCHasID<IMPLTYPE>,IHCHasName<IMPLTYPE>,IHCNode,Serializable
- Direct Known Subclasses:
HCSelect
public abstract class AbstractHCSelect<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>> extends AbstractHCControl<IMPLTYPE> implements IHCSelect<IMPLTYPE>
Represents an HTML <select> element- Author:
- Philip Helger
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_MULTIPLEBy default multi select is disabled-
Fields inherited from class com.helger.html.hc.html.forms.AbstractHCControl
CSS_CLASS_READ_ONLY, DEFAULT_AUTO_FOCUS, DEFAULT_DISABLED, DEFAULT_READ_ONLY, DEFAULT_REQUIRED
-
Fields inherited from class com.helger.html.hc.html.AbstractHCElement
DEFAULT_HIDDEN, DEFAULT_SPELLCHECK, DEFAULT_TRANSLATE, DEFAULT_UNFOCUSABLE
-
Fields inherited from interface com.helger.html.hc.html.IHCElement
DEFAULT_TABINDEX
-
-
Constructor Summary
Constructors Constructor Description AbstractHCSelect()AbstractHCSelect(IHCRequestField aRF)AbstractHCSelect(IHCRequestFieldMultiValue aRF)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HCOptionaddOption(HCOption aOption)HCOptionaddOptionAt(int nIndex, HCOption aOption)Add a new option at the specified index.IMPLTYPEaddOptionGroup(HCOptGroup aOptGroup)com.helger.commons.collection.impl.ICommonsList<IHCNode>children()protected voidfillMicroElement(com.helger.xml.microdom.IMicroElement aElement, IHCConversionSettingsToNode aConversionSettings)Set all attributes and child elements of this objectcom.helger.commons.collection.impl.ICommonsList<IHCNode>getAllChildren()com.helger.commons.collection.impl.ICommonsList<HCOptGroup>getAllOptionGroups()com.helger.commons.collection.impl.ICommonsList<HCOption>getAllOptions()com.helger.commons.collection.impl.ICommonsSet<String>getAllPreselectedValues()com.helger.commons.collection.impl.ICommonsList<HCOption>getAllSelectedOptions()IHCNodegetChildAtIndex(int nIndex)intgetChildCount()com.helger.commons.collection.impl.ICommonsIterable<IHCNode>getChildren()IHCNodegetFirstChild()HCOptiongetFirstSelectedOption()StringgetForm()IHCNodegetLastChild()HCOptiongetOptionAtIndex(int nIndex)Get the option at the specified indexintgetOptionCount()HCOptGroupgetOptionGroupAtIndex(int nIndex)Get the option group at the specified indexintgetOptionGroupCount()intgetSelectedOptionCount()intgetSize()booleanhasChildren()booleanhasOptionGroups()booleanhasOptions()booleanhasSelectedOption()Check if this select has at least one selected optionbooleanisMultiple()booleanisPreselectedValue(String sValue)protected voidonAddOption(HCOption aOption)CallbackIMPLTYPEremoveAllOptionGroups()IMPLTYPEremoveAllOptions()IMPLTYPEremoveOptionAt(int nIndex)Remove the option at the specified index.IMPLTYPEremoveOptionGroupAt(int nIndex)Remove the option group at the specified index.IMPLTYPEsetForm(String sForm)IMPLTYPEsetMultiple(boolean bMultiple)IMPLTYPEsetSize(int nSize)StringtoString()-
Methods inherited from class com.helger.html.hc.html.forms.AbstractHCControl
getName, isAutoFocus, isDisabled, isReadOnly, isRequired, onFinalizeNodeState, setAutoFocus, setDisabled, setName, setReadOnly, setRequired
-
Methods inherited from class com.helger.html.hc.html.AbstractHCElement
addClass, addEventHandler, addStyle, containsClass, containsEventHandler, containsStyle, createMicroElement, customAttrs, finishMicroElement, getAccessKey, getAllClasses, getAllClassesAsString, getAllClassNames, getAllStyles, getAllStylesAsString, getAllStyleValues, getContentEditable, getDirection, getDraggable, getElement, getEventHandler, getEventMap, getID, getLanguage, getRole, getStyleValue, getTabIndex, getTagName, getTitle, getTranslate, hasAnyClass, hasAnyStyle, hasStyle, internalConvertToMicroNode, isHidden, isSpellCheck, isTranslateOff, isTranslateOn, isTranslateUndefined, isUnfocusable, isValidID, onConsistencyCheck, prependEventHandler, removeAllClasses, removeAllEventHandler, removeAllStyles, removeClass, removeStyle, setAccessKey, setContentEditable, setDirection, setDraggable, setEventHandler, setHidden, setID, setID, setLanguage, setRole, setSpellCheck, setTabIndex, setTitle, setTranslate, setUnfocusable
-
Methods inherited from class com.helger.html.hc.impl.AbstractHCNode
canConvertToMicroNode, consistencyCheck, convertToMicroNode, customizeNode, finalizeNodeState, findFirstChild, findFirstChildMapped, forAllChildren, forAllChildren, forAllChildrenBreakable, forAllChildrenMapped, getNodeState, getPlainText, internalSetNodeState, onCustomizeNode, onRegisterExternalResources, registerExternalResources
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.helger.commons.hierarchy.IHasChildren
forAllChildren, forAllChildren, forAllChildrenBreakable, forAllChildrenMapped, hasNoChildren
-
Methods inherited from interface com.helger.commons.hierarchy.IHasChildrenRecursive
forAllChildrenRecursive, forAllChildrenRecursive
-
Methods inherited from interface com.helger.commons.hierarchy.IHasChildrenSorted
findFirstChild, findFirstChildMapped
-
Methods inherited from interface com.helger.html.hc.html.forms.IHCControl
isReadOnly, isRequired, setReadOnly, setRequired
-
Methods inherited from interface com.helger.html.hc.html.IHCElement
addEventHandler, containsEventHandler, customAttrs, getAccessKey, getContentEditable, getDirection, getDraggable, getElement, getEventHandler, getEventMap, getLanguage, getRole, getTabIndex, getTagName, getTitle, getTranslate, isHidden, isSpellCheck, isTranslateOff, isTranslateOn, isTranslateUndefined, isUnfocusable, prependEventHandler, removeAllEventHandler, setAccessKey, setContentEditable, setDirection, setDraggable, setEventHandler, setHidden, setLanguage, setRole, setSpellCheck, setTabIndex, setTitle, setTranslate, setTranslate, setUnfocusable, withCustomAttrs
-
Methods inherited from interface com.helger.html.hc.html.IHCHasCSSClasses
addClass, addClasses, addClasses, addClasses, containsClass, getAllClasses, getAllClassesAsString, getAllClassNames, hasAnyClass, removeAllClasses, removeClass
-
Methods inherited from interface com.helger.html.hc.html.IHCHasCSSStyles
addStyle, addStyle, addStyles, addStyles, addStyles, containsStyle, getAllStyles, getAllStylesAsString, getAllStyleValues, getStyleValue, hasAnyStyle, hasStyle, removeAllStyles, removeStyle
-
Methods inherited from interface com.helger.html.hc.IHCHasID
ensureID, getID, hasID, hasNoID, setID, setUniqueID
-
Methods inherited from interface com.helger.html.hc.IHCHasName
getName, setName
-
Methods inherited from interface com.helger.html.hc.html.IHCHasState
isDisabled, setDisabled
-
Methods inherited from interface com.helger.html.hc.IHCNode
canConvertToMicroNode, consistencyCheck, convertToMicroNode, customizeNode, finalizeNodeState, getNodeState, getPlainText, registerExternalResources
-
Methods inherited from interface com.helger.html.hc.html.forms.IHCSelect
addOption, addOption, addOption, addOption, addOption, addOptionAt, getFirstSelectedOptionValue, isAutoFocus, setAutoFocus
-
-
-
-
Field Detail
-
DEFAULT_MULTIPLE
public static final boolean DEFAULT_MULTIPLE
By default multi select is disabled- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractHCSelect
public AbstractHCSelect()
-
AbstractHCSelect
public AbstractHCSelect(@Nonnull IHCRequestField aRF)
-
AbstractHCSelect
public AbstractHCSelect(@Nonnull IHCRequestFieldMultiValue aRF)
-
-
Method Detail
-
getForm
@Nullable public final String getForm()
- Specified by:
getFormin interfaceIHCSelect<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>
-
setForm
@Nonnull public final IMPLTYPE setForm(@Nullable String sForm)
- Specified by:
setFormin interfaceIHCSelect<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>
-
isMultiple
public final boolean isMultiple()
- Specified by:
isMultiplein interfaceIHCSelect<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>
-
setMultiple
@Nonnull public final IMPLTYPE setMultiple(boolean bMultiple)
- Specified by:
setMultiplein interfaceIHCSelect<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>
-
getSize
public final int getSize()
- Specified by:
getSizein interfaceIHCSelect<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>
-
setSize
@Nonnull public final IMPLTYPE setSize(int nSize)
- Specified by:
setSizein interfaceIHCSelect<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>
-
getAllPreselectedValues
@Nonnull @ReturnsMutableCopy public final com.helger.commons.collection.impl.ICommonsSet<String> getAllPreselectedValues()
- Specified by:
getAllPreselectedValuesin interfaceIHCSelect<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>
-
isPreselectedValue
public final boolean isPreselectedValue(@Nullable String sValue)
- Specified by:
isPreselectedValuein interfaceIHCSelect<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>
-
onAddOption
@OverrideOnDemand protected void onAddOption(@Nonnull HCOption aOption)
Callback- Parameters:
aOption- The added option. Nevernull.
-
addOption
@Nonnull public final HCOption addOption(@Nonnull HCOption aOption)
- Specified by:
addOptionin interfaceIHCSelect<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>
-
addOptionAt
@Nonnull public final HCOption addOptionAt(@Nonnegative int nIndex, @Nonnull HCOption aOption)
Description copied from interface:IHCSelectAdd a new option at the specified index.- Specified by:
addOptionAtin interfaceIHCSelect<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>- Parameters:
nIndex- The index to use. Should be ≥ 0.aOption- The option to be added. May not benull.- Returns:
- this for chaining
-
addOptionGroup
@Nonnull public final IMPLTYPE addOptionGroup(@Nullable HCOptGroup aOptGroup)
- Specified by:
addOptionGroupin interfaceIHCSelect<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>
-
removeAllOptions
@Nonnull public final IMPLTYPE removeAllOptions()
- Specified by:
removeAllOptionsin interfaceIHCSelect<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>
-
removeAllOptionGroups
@Nonnull public final IMPLTYPE removeAllOptionGroups()
- Specified by:
removeAllOptionGroupsin interfaceIHCSelect<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>
-
removeOptionAt
@Nonnull public final IMPLTYPE removeOptionAt(@Nonnegative int nIndex)
Description copied from interface:IHCSelectRemove the option at the specified index.- Specified by:
removeOptionAtin interfaceIHCSelect<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>- Parameters:
nIndex- The index to be removed. Should be ≥ 0.- Returns:
- this for chaining
-
removeOptionGroupAt
@Nonnull public final IMPLTYPE removeOptionGroupAt(@Nonnegative int nIndex)
Description copied from interface:IHCSelectRemove the option group at the specified index.- Specified by:
removeOptionGroupAtin interfaceIHCSelect<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>- Parameters:
nIndex- The index to be removed. Should be ≥ 0.- Returns:
- this for chaining
-
getOptionCount
@Nonnegative public final int getOptionCount()
- Specified by:
getOptionCountin interfaceIHCSelect<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>- Returns:
- The number of available options.
-
getOptionGroupCount
@Nonnegative public final int getOptionGroupCount()
- Specified by:
getOptionGroupCountin interfaceIHCSelect<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>- Returns:
- The number of available option groups.
-
getAllOptions
@Nonnull @ReturnsMutableCopy public final com.helger.commons.collection.impl.ICommonsList<HCOption> getAllOptions()
- Specified by:
getAllOptionsin interfaceIHCSelect<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>- Returns:
- A non-
nulllist of all available options.
-
getAllOptionGroups
@Nonnull @ReturnsMutableCopy public final com.helger.commons.collection.impl.ICommonsList<HCOptGroup> getAllOptionGroups()
- Specified by:
getAllOptionGroupsin interfaceIHCSelect<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>- Returns:
- A non-
nulllist of all available option groups.
-
getOptionAtIndex
@Nullable public final HCOption getOptionAtIndex(@Nonnegative int nIndex)
Description copied from interface:IHCSelectGet the option at the specified index- Specified by:
getOptionAtIndexin interfaceIHCSelect<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>- Parameters:
nIndex- The index to retrieve. Should always be ≥ 0.- Returns:
nullif no option is available for the specified index.
-
getOptionGroupAtIndex
@Nullable public final HCOptGroup getOptionGroupAtIndex(@Nonnegative int nIndex)
Description copied from interface:IHCSelectGet the option group at the specified index- Specified by:
getOptionGroupAtIndexin interfaceIHCSelect<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>- Parameters:
nIndex- The index to retrieve. Should always be ≥ 0.- Returns:
nullif no option group is available for the specified index.
-
hasOptions
public final boolean hasOptions()
- Specified by:
hasOptionsin interfaceIHCSelect<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>- Returns:
trueif this select has at least one option.
-
hasOptionGroups
public final boolean hasOptionGroups()
- Specified by:
hasOptionGroupsin interfaceIHCSelect<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>- Returns:
trueif this select has at least one option group.
-
getAllSelectedOptions
@Nonnull @ReturnsMutableCopy public final com.helger.commons.collection.impl.ICommonsList<HCOption> getAllSelectedOptions()
- Specified by:
getAllSelectedOptionsin interfaceIHCSelect<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>- Returns:
- A non-
nulllist of all selected options.
-
getFirstSelectedOption
@Nullable public HCOption getFirstSelectedOption()
- Specified by:
getFirstSelectedOptionin interfaceIHCSelect<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>- Returns:
- The first selected option. May be
null.
-
getSelectedOptionCount
@Nonnegative public final int getSelectedOptionCount()
- Specified by:
getSelectedOptionCountin interfaceIHCSelect<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>- Returns:
- The number of selected options. Always ≥ 0.
-
hasSelectedOption
public final boolean hasSelectedOption()
Description copied from interface:IHCSelectCheck if this select has at least one selected option- Specified by:
hasSelectedOptionin interfaceIHCSelect<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>- Returns:
trueif at least one option is selected
-
children
@Nullable @ReturnsMutableObject public final com.helger.commons.collection.impl.ICommonsList<IHCNode> children()
-
getAllChildren
@Nullable @ReturnsMutableCopy public final com.helger.commons.collection.impl.ICommonsList<IHCNode> getAllChildren()
- Specified by:
getAllChildrenin interfacecom.helger.commons.hierarchy.IHasChildren<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>- Specified by:
getAllChildrenin interfacecom.helger.commons.hierarchy.IHasChildrenSorted<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>- Overrides:
getAllChildrenin classAbstractHCNode
-
getChildren
@Nonnull @ReturnsImmutableObject public final com.helger.commons.collection.impl.ICommonsIterable<IHCNode> getChildren()
- Specified by:
getChildrenin interfacecom.helger.commons.hierarchy.IHasChildren<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>- Overrides:
getChildrenin classAbstractHCNode
-
getChildAtIndex
@Nullable public final IHCNode getChildAtIndex(int nIndex)
- Specified by:
getChildAtIndexin interfacecom.helger.commons.hierarchy.IHasChildrenSorted<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>- Overrides:
getChildAtIndexin classAbstractHCNode
-
getFirstChild
@Nullable public final IHCNode getFirstChild()
- Specified by:
getFirstChildin interfacecom.helger.commons.hierarchy.IHasChildrenSorted<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>- Overrides:
getFirstChildin classAbstractHCNode
-
getLastChild
@Nullable public final IHCNode getLastChild()
- Specified by:
getLastChildin interfacecom.helger.commons.hierarchy.IHasChildrenSorted<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>- Overrides:
getLastChildin classAbstractHCNode
-
hasChildren
public final boolean hasChildren()
- Specified by:
hasChildrenin interfacecom.helger.commons.hierarchy.IHasChildren<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>- Overrides:
hasChildrenin classAbstractHCNode
-
getChildCount
public final int getChildCount()
- Specified by:
getChildCountin interfacecom.helger.commons.hierarchy.IHasChildren<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>- Overrides:
getChildCountin classAbstractHCNode
-
fillMicroElement
protected void fillMicroElement(com.helger.xml.microdom.IMicroElement aElement, IHCConversionSettingsToNode aConversionSettings)Description copied from class:AbstractHCElementSet all attributes and child elements of this object- Overrides:
fillMicroElementin classAbstractHCControl<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>- Parameters:
aElement- The current micro element to be filled. Nevernull.aConversionSettings- The conversion settings to be used. Nevernull.
-
toString
public String toString()
- Overrides:
toStringin classAbstractHCControl<IMPLTYPE extends AbstractHCSelect<IMPLTYPE>>
-
-