org.apache.wicket.markup.html.form
Class AbstractSingleSelectChoice<T>
java.lang.Object
org.apache.wicket.Component
org.apache.wicket.MarkupContainer
org.apache.wicket.markup.html.WebMarkupContainer
org.apache.wicket.markup.html.form.LabeledWebMarkupContainer
org.apache.wicket.markup.html.form.FormComponent<T>
org.apache.wicket.markup.html.form.AbstractChoice<T,T>
org.apache.wicket.markup.html.form.AbstractSingleSelectChoice<T>
- Type Parameters:
T
- The model object type
- All Implemented Interfaces:
- java.io.Serializable, IClusterable, IConverterLocator, IFormModelUpdateListener, IFormVisitorParticipant, ILabelProvider<java.lang.String>
- Direct Known Subclasses:
- DropDownChoice, RadioChoice
public abstract class AbstractSingleSelectChoice<T>
- extends AbstractChoice<T,T>
Abstract base class for single-select choices.
- Author:
- Jonathan Locke, Eelco Hillenius, Johan Compagner
- See Also:
- Serialized Form
Fields inherited from class org.apache.wicket.Component |
ENABLE, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED6, FLAG_RESERVED7, FLAG_RESERVED8, PATH_SEPARATOR, RENDER |
Constructor Summary |
AbstractSingleSelectChoice(java.lang.String id)
|
AbstractSingleSelectChoice(java.lang.String id,
IModel<? extends java.util.List<? extends T>> choices)
|
AbstractSingleSelectChoice(java.lang.String id,
IModel<? extends java.util.List<? extends T>> choices,
IChoiceRenderer<T> renderer)
|
AbstractSingleSelectChoice(java.lang.String id,
IModel<T> model,
IModel<? extends java.util.List<? extends T>> choices)
|
AbstractSingleSelectChoice(java.lang.String id,
IModel<T> model,
IModel<? extends java.util.List<? extends T>> choices,
IChoiceRenderer<T> renderer)
|
AbstractSingleSelectChoice(java.lang.String id,
IModel<T> model,
java.util.List<? extends T> data)
|
AbstractSingleSelectChoice(java.lang.String id,
IModel<T> model,
java.util.List<? extends T> data,
IChoiceRenderer<T> renderer)
|
AbstractSingleSelectChoice(java.lang.String id,
java.util.List<? extends T> choices)
|
AbstractSingleSelectChoice(java.lang.String id,
java.util.List<? extends T> data,
IChoiceRenderer<T> renderer)
|
Method Summary |
protected T |
convertChoiceIdToChoice(java.lang.String id)
Converts submitted choice id string back to choice object. |
protected T |
convertValue(java.lang.String[] value)
Subclasses should overwrite this if the conversion is not done through the type field and the
IConverter . |
protected java.lang.CharSequence |
getDefaultChoice(java.lang.Object selected)
The localizer will be ask for the property to display Depending on if null is allowed or not
it will ask for:
nullValid: when null is valid and by default it will show an empty string as a choice.
null: when null is not a valid choice and it will make a choice with "Choose One"
The choice for null is valid will always be returned. |
java.lang.String |
getModelValue()
|
protected java.lang.Object |
getNoSelectionValue()
In case "-1" is not a suitable "no selection value", you may provide your own implementation
of getNoSelectionValue(). |
boolean |
isNullValid()
Is the null value a valid value? If it is, it means that the null value will be
displayed, typically to the user as 'choose one' or something similar. |
protected boolean |
isSelected(T object,
int index,
java.lang.String selected)
Gets whether the given value represents the current selection. |
AbstractSingleSelectChoice<T> |
setNullValid(boolean nullValid)
Is the null value a valid value? If it is, it means that the null value will be
displayed, typically to the user as 'choose one' or something similar. |
Methods inherited from class org.apache.wicket.markup.html.form.AbstractChoice |
appendOptionHtml, detachModel, escapeOptionHtml, getChoiceRenderer, getChoices, isDisabled, localizeDisplayValues, onComponentTagBody, setChoiceRenderer, setChoices, setChoices, supportsPersistence |
Methods inherited from class org.apache.wicket.markup.html.form.FormComponent |
add, add, checkRequired, clearInput, convertInput, error, getConvertedInput, getForm, getInput, getInputAsArray, getInputName, getModel, getModelObject, getRawInput, getType, getValidatorKeyPrefix, getValidators, getValue, hasRawInput, inputAsInt, inputAsInt, inputAsIntArray, inputChanged, internalOnModelChanged, invalid, isInputNullable, isMultiPart, isPersistent, isRequired, isValid, newValidatable, onComponentTag, onDetach, onDisabled, onInvalid, onValid, processChildren, processInput, setConvertedInput, setLabel, setModel, setModelObject, setModelValue, setModelValue, setPersistent, setRequired, setType, shouldTrimInput, trim, updateModel, valid, validate, validateRequired, validateValidators, visitComponentsPostOrder, visitFormComponentsPostOrder |
Methods inherited from class org.apache.wicket.MarkupContainer |
add, addOrReplace, autoAdd, autoAdd, contains, findMarkupStream, get, get, getAssociatedMarkupStream, getMarkupStream, hasAssociatedMarkup, internalAdd, isTransparentResolver, iterator, iterator, newMarkupResourceStream, onRender, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderComponentTagBody, replace, setDefaultModel, setMarkupStream, size, swap, toString, toString, visitChildren, visitChildren |
Methods inherited from class org.apache.wicket.Component |
add, addStateChange, afterRender, beforeRender, callOnBeforeRenderIfNotVisible, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, continueToOriginalDestination, debug, detach, detachBehaviors, detachModels, determineVisibility, error, exceptionMessage, fatal, findPage, findParent, findParentWithAssociatedMarkup, getApplication, getBehaviors, getBehaviors, getBehaviorsRawList, getClassRelativePath, getComponentBorder, getConverter, getConverter, getDefaultModel, getDefaultModelObject, getDefaultModelObjectAsString, getDefaultModelObjectAsString, getEscapeModelStrings, getFeedbackMessage, getFlag, getFlag, getId, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkupAttributes, getMarkupId, getMarkupId, getMarkupIdImpl, getMetaData, getModelComparator, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getResponse, getSession, getSizeInBytes, getStatelessHint, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalAttach, internalDetach, internalOnAttach, internalOnDetach, isActionAuthorized, isAncestorOf, isAttached, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isRenderAllowed, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, locateMarkupStream, markAttached, markRendering, modelChanged, modelChanging, onAfterRender, onAttach, onBeforeRender, onBeginRequest, onEndRequest, onModelChanged, onModelChanging, prepareForRender, prepareForRender, redirectToInterceptPage, remove, remove, render, render, renderComponent, renderComponent, renderComponentTag, rendered, renderHead, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, setAuto, setComponentBorder, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setFlag, setIgnoreAttributeModifier, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setRedirect, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, urlFor, urlFor, urlFor, urlFor, urlFor, urlFor, visitParents, warn, wrap |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
NO_SELECTION_VALUE
protected static final java.lang.Object NO_SELECTION_VALUE
AbstractSingleSelectChoice
public AbstractSingleSelectChoice(java.lang.String id)
- See Also:
AbstractChoice.AbstractChoice(String)
AbstractSingleSelectChoice
public AbstractSingleSelectChoice(java.lang.String id,
java.util.List<? extends T> choices)
- See Also:
AbstractChoice.AbstractChoice(String, List)
AbstractSingleSelectChoice
public AbstractSingleSelectChoice(java.lang.String id,
java.util.List<? extends T> data,
IChoiceRenderer<T> renderer)
- Parameters:
id
- data
- renderer
- - See Also:
AbstractChoice.AbstractChoice(String, List ,IChoiceRenderer)
AbstractSingleSelectChoice
public AbstractSingleSelectChoice(java.lang.String id,
IModel<T> model,
java.util.List<? extends T> data)
- See Also:
AbstractChoice.AbstractChoice(String, IModel, List)
AbstractSingleSelectChoice
public AbstractSingleSelectChoice(java.lang.String id,
IModel<T> model,
java.util.List<? extends T> data,
IChoiceRenderer<T> renderer)
- Parameters:
id
- model
- data
- renderer
- - See Also:
AbstractChoice.AbstractChoice(String, IModel, List, IChoiceRenderer)
AbstractSingleSelectChoice
public AbstractSingleSelectChoice(java.lang.String id,
IModel<? extends java.util.List<? extends T>> choices)
- See Also:
AbstractChoice.AbstractChoice(String, IModel)
AbstractSingleSelectChoice
public AbstractSingleSelectChoice(java.lang.String id,
IModel<T> model,
IModel<? extends java.util.List<? extends T>> choices)
- See Also:
AbstractChoice.AbstractChoice(String, IModel,IModel)
AbstractSingleSelectChoice
public AbstractSingleSelectChoice(java.lang.String id,
IModel<? extends java.util.List<? extends T>> choices,
IChoiceRenderer<T> renderer)
- See Also:
AbstractChoice.AbstractChoice(String,
IModel,IChoiceRenderer)
AbstractSingleSelectChoice
public AbstractSingleSelectChoice(java.lang.String id,
IModel<T> model,
IModel<? extends java.util.List<? extends T>> choices,
IChoiceRenderer<T> renderer)
- See Also:
AbstractChoice.AbstractChoice(String, IModel,
IModel,IChoiceRenderer)
getNoSelectionValue
protected java.lang.Object getNoSelectionValue()
- In case "-1" is not a suitable "no selection value", you may provide your own implementation
of getNoSelectionValue(). The return Object's toString() will be used as the
"no selection value". Object.equals() must return true when equal. Thus besides special
object, simply returning a String (e.g. "999") would be ok as well.
By default NO_SELECTION_VALUE will be returned.
By purpose there is no setter for the "no selection object". You should add the variable to
your subclass.
- Returns:
- The "no selection object"
getModelValue
public java.lang.String getModelValue()
- Overrides:
getModelValue
in class FormComponent<T>
- Returns:
- Value to return when model value is needed
- See Also:
FormComponent.getModelValue()
isNullValid
public boolean isNullValid()
- Is the
null
value a valid value? If it is, it means that the null value will be
displayed, typically to the user as 'choose one' or something similar. Note that this doesn't
say anything about whether a null value (not selecting a value) is permitted; use
FormComponent.setRequired(boolean)
for that.
- Returns:
true
when the null
value is allowed.
setNullValid
public AbstractSingleSelectChoice<T> setNullValid(boolean nullValid)
- Is the
null
value a valid value? If it is, it means that the null value will be
displayed, typically to the user as 'choose one' or something similar. Note that this doesn't
say anything about whether a null value (not selecting a value) is permitted; use
FormComponent.setRequired(boolean)
for that.
- Parameters:
nullValid
- whether null is a valid value
- Returns:
- this for chaining
convertValue
protected final T convertValue(java.lang.String[] value)
- Description copied from class:
FormComponent
- Subclasses should overwrite this if the conversion is not done through the type field and the
IConverter
. WARNING: this method may be removed in future versions.
If conversion fails then a ConversionException should be thrown
- Overrides:
convertValue
in class FormComponent<T>
- Parameters:
value
- The value can be the getInput() or through a cookie
- Returns:
- The converted value. default returns just the given value
- See Also:
FormComponent.convertValue(String[])
convertChoiceIdToChoice
protected T convertChoiceIdToChoice(java.lang.String id)
- Converts submitted choice id string back to choice object.
- Parameters:
id
- string id of one of the choice objects in the choices list. can be null.
- Returns:
- choice object. null if none match the specified id.
getDefaultChoice
protected java.lang.CharSequence getDefaultChoice(java.lang.Object selected)
- The localizer will be ask for the property to display Depending on if null is allowed or not
it will ask for:
- nullValid: when null is valid and by default it will show an empty string as a choice.
- null: when null is not a valid choice and it will make a choice with "Choose One"
The choice for null is valid will always be returned. The choice when null is not valid will
only be returned if the selected object is null.
- Overrides:
getDefaultChoice
in class AbstractChoice<T,T>
- Parameters:
selected
- The object that's currently selected
- Returns:
- Any default choice, such as "Choose One", depending on the subclass
- See Also:
AbstractChoice.getDefaultChoice(Object)
isSelected
protected boolean isSelected(T object,
int index,
java.lang.String selected)
- Gets whether the given value represents the current selection.
aram object The object to check
- Specified by:
isSelected
in class AbstractChoice<T,T>
- Parameters:
index
- The index of the object in the collectionselected
- The current selected id valueobject
- The object to check
- Returns:
- Whether the given value represents the current selection
Copyright © 2004-2009 Apache Software Foundation. All Rights Reserved.