T
- The model object typepublic abstract class AbstractSingleSelectChoice<T> extends AbstractChoice<T,T>
AbstractChoice.LabelPosition
FLAG_CONVERT_EMPTY_INPUT_STRING_TO_NULL, VALUE_SEPARATOR
ENABLE, FLAG_AFTER_RENDERING, FLAG_INITIALIZED, FLAG_PREPARED_FOR_RENDER, FLAG_REMOVING_FROM_HIERARCHY, FLAG_RENDERING, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER, RFLAG_CONTAINER_DEQUEING
Constructor and Description |
---|
AbstractSingleSelectChoice(String id)
Constructor.
|
AbstractSingleSelectChoice(String id,
IModel<? extends List<? extends T>> choices)
Constructor.
|
AbstractSingleSelectChoice(String id,
IModel<? extends List<? extends T>> choices,
IChoiceRenderer<? super T> renderer)
Constructor.
|
AbstractSingleSelectChoice(String id,
IModel<T> model,
IModel<? extends List<? extends T>> choices)
Constructor.
|
AbstractSingleSelectChoice(String id,
IModel<T> model,
IModel<? extends List<? extends T>> choices,
IChoiceRenderer<? super T> renderer)
Constructor.
|
AbstractSingleSelectChoice(String id,
IModel<T> model,
List<? extends T> choices)
Constructor.
|
AbstractSingleSelectChoice(String id,
IModel<T> model,
List<? extends T> choices,
IChoiceRenderer<? super T> renderer)
Constructor.
|
AbstractSingleSelectChoice(String id,
List<? extends T> choices)
Constructor.
|
AbstractSingleSelectChoice(String id,
List<? extends T> choices,
IChoiceRenderer<? super T> renderer)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected T |
convertChoiceIdToChoice(String id)
Converts submitted choice id string back to choice object.
|
protected T |
convertValue(String[] value)
Subclasses should overwrite this if the conversion is not done through the type field and the
IConverter . |
protected CharSequence |
getDefaultChoice(String selectedValue)
Asks the
Localizer for the property to display for an additional default choice
depending on isNullValid() :
"nullValid" if null is valid, defaulting to an empty string.
"null" if null is not valid but no choice is selected (i.e. |
String |
getModelValue() |
protected String |
getNullKey()
Return the localization key for null value
|
protected String |
getNullKeyDisplayValue()
Returns the display value if null is not valid but is selected.
|
protected String |
getNullValidDisplayValue()
Returns the display value for the null value.
|
protected String |
getNullValidKey()
Return the localization key for nullValid value
|
boolean |
isNullValid()
Determines whether or not the null value should be included in the list of choices when the
field's model value is nonnull, and whether or not the null_valid string property (e.g.
|
protected boolean |
isSelected(T object,
int index,
String selected)
Gets whether the given value represents the current selection.
|
AbstractSingleSelectChoice<T> |
setNullValid(boolean nullValid)
Determines whether or not the null value should be included in the list of choices when the
field's model value is nonnull, and whether or not the null_valid string property (e.g.
|
appendOptionHtml, detachModel, escapeOptionHtml, getChoiceRenderer, getChoices, getChoicesModel, isDisabled, localizeDisplayValues, onComponentTagBody, setChoiceRenderer, setChoices, setChoices, setOptionAttributes, setType
add, add, checkRequired, clearInput, convertInput, error, getConvertedInput, getDefaultLabel, getDefaultLabel, getForm, getInput, getInputAsArray, getInputName, getModel, getModelObject, getRawInput, getType, getValidatorKeyPrefix, getValidators, getValue, hasRawInput, inputAsInt, inputAsInt, inputAsIntArray, inputChanged, internalOnModelChanged, invalid, isInputNullable, isMultiPart, isRequired, isValid, newValidatable, newValidationError, onComponentTag, onDetach, onDisabled, onInvalid, onRequired, onValid, processChildren, processInput, remove, reportRequiredError, setConvertedInput, setLabel, setModel, setModelObject, setModelValue, setRequired, shouldTrimInput, trim, updateAutoLabels, updateCollectionModel, updateModel, valid, validate, validateRequired, validateValidators, visitComponentsPostOrder, visitFormComponentsPostOrder
getLabel
getWebPage, getWebRequest, getWebResponse, getWebSession
add, addDequeuedComponent, addOrReplace, autoAdd, canDequeueTag, contains, dequeue, dequeue, dequeuePreamble, findComponentToDequeue, get, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getMarkupType, internalAdd, internalInitialize, iterator, iterator, newDequeueContext, onAfterRenderChildren, onInitialize, onRender, queue, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderNext, replace, setDefaultModel, size, swap, toString, toString, visitChildren, visitChildren, visitChildren, visitChildren
add, addStateChange, afterRender, beforeRender, canCallListenerInterface, canCallListenerInterfaceAfterExpiry, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, clearOriginalDestination, configure, continueToOriginalDestination, debug, detach, detachModels, determineVisibility, error, exceptionMessage, fatal, findMarkupStream, findPage, findParent, findParentWithAssociatedMarkup, getAjaxRegionMarkupId, getApplication, getBehaviorById, getBehaviorId, getBehaviors, getBehaviors, getClassRelativePath, getConverter, getDefaultModel, getDefaultModelObject, getDefaultModelObjectAsString, getDefaultModelObjectAsString, getEscapeModelStrings, getFeedbackMessages, getFlag, getId, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkup, getMarkupAttributes, getMarkupId, getMarkupId, getMarkupIdFromMarkup, getMarkupIdImpl, getMarkupSourcingStrategy, getMetaData, getModelComparator, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getRequestFlag, getResponse, getSession, getSizeInBytes, getStatelessHint, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalPrepareForRender, internalRenderComponent, internalRenderHead, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isRenderAllowed, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, newMarkupSourcingStrategy, onAfterRender, onBeforeRender, onConfigure, onEvent, onModelChanged, onModelChanging, onReAdd, onRemove, prepareForRender, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, renderHead, renderHead, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, send, setAuto, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setIgnoreAttributeModifier, setMarkup, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setParent, setRenderBodyOnly, setRequestFlag, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, success, urlFor, urlFor, urlFor, urlFor, urlFor, visitParents, visitParents, warn, wrap
public AbstractSingleSelectChoice(String id)
id
- See Componentpublic AbstractSingleSelectChoice(String id, List<? extends T> choices)
id
- See Componentchoices
- The collection of choices in the dropdownpublic AbstractSingleSelectChoice(String id, List<? extends T> choices, IChoiceRenderer<? super T> renderer)
id
- See Componentrenderer
- The rendering enginechoices
- The collection of choices in the dropdownpublic AbstractSingleSelectChoice(String id, IModel<T> model, List<? extends T> choices)
id
- See Componentmodel
- See Componentchoices
- The collection of choices in the dropdownpublic AbstractSingleSelectChoice(String id, IModel<T> model, List<? extends T> choices, IChoiceRenderer<? super T> renderer)
id
- See Componentmodel
- See Componentchoices
- The drop down choicesrenderer
- The rendering enginepublic AbstractSingleSelectChoice(String id, IModel<? extends List<? extends T>> choices)
id
- See Componentchoices
- The collection of choices in the dropdownpublic AbstractSingleSelectChoice(String id, IModel<T> model, IModel<? extends List<? extends T>> choices)
id
- See Componentmodel
- See Componentchoices
- The drop down choicespublic AbstractSingleSelectChoice(String id, IModel<? extends List<? extends T>> choices, IChoiceRenderer<? super T> renderer)
id
- See Componentchoices
- The drop down choicesrenderer
- The rendering enginepublic String getModelValue()
getModelValue
in class FormComponent<T>
FormComponent.getModelValue()
public boolean isNullValid()
FormComponent.setRequired(boolean)
. This is because even if
setNullValid() is called with false, the user can fail to provide a value simply by never
activating (i.e. clicking on) the component.true
when the null
value is allowed.public AbstractSingleSelectChoice<T> setNullValid(boolean nullValid)
FormComponent.setRequired(boolean)
. This is because even if
setNullValid() is called with false, the user can fail to provide a value simply by never
activating (i.e. clicking on) the component.nullValid
- whether null is a valid valueprotected final T convertValue(String[] value)
FormComponent
IConverter
. WARNING: this method may be removed in future versions.
If conversion fails then a ConversionException should be thrownconvertValue
in class FormComponent<T>
value
- The value can be the getInput() or through a cookieFormComponent.convertValue(String[])
protected T convertChoiceIdToChoice(String id)
id
- string id of one of the choice objects in the choices list. can be null.protected CharSequence getDefaultChoice(String selectedValue)
Localizer
for the property to display for an additional default choice
depending on isNullValid()
:
null
is valid, defaulting to an empty string.null
is not valid but no choice is selected (i.e. selectedValue
is
empty), defaulting to "Choose one".getDefaultChoice
in class AbstractChoice<T,T>
selectedValue
- The currently selected valuegetNullValidKey()
,
getNullKey()
,
AbstractChoice.getDefaultChoice(String)
protected String getNullValidDisplayValue()
getNullValidKey()
.protected String getNullValidKey()
protected String getNullKeyDisplayValue()
getNullKey()
.protected String getNullKey()
protected boolean isSelected(T object, int index, String selected)
isSelected
in class AbstractChoice<T,T>
object
- The object to checkindex
- The index of the object in the collectionselected
- The current selected id valueCopyright © 2006–2014 Apache Software Foundation. All rights reserved.