T
- public class Select<T> extends FormComponent<T>
<select>
box. Elements are provided by one or more
SelectOptions
components in the hierarchy below the Select
component.
Advantages to the standard choice components is that the user has a lot more control over the
markup between the <select> tag and its children <option> tags: allowing for such
things as <optgroup> tags.
Example HTML:
<select wicket:id="select" multiple="multiple"> <wicket:container wicket:id="options"> <option wicket:id="option">Option Label</option> </wicket:container> </select>Related Java Code:
Select select = new Select("select", selectionModel); add(select); SelectOptions options = new SelectOptions("options", elements, renderer); select.add(options);Note that you don't need to add component(s) for the <option> tag - they are created by SelectOptions
Note: due to the usage of a SelectOption for each <option> the memory
footprint of the page will grow with the number of <option>s you need. Consider using
DropDownChoice
component if it is able to fulfill your
requirements.
SelectOption
,
SelectOptions
,
DropDownChoice
,
Serialized FormFLAG_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 |
---|
Select(String id)
Constructor that will create a default model collection
|
Select(String id,
IModel<T> model) |
Modifier and Type | Method and Description |
---|---|
void |
convertInput()
Converts and validates the conversion of the raw input string into the object specified by
FormComponent.getType() and records any thrown ConversionException s. |
protected String |
getModelValue() |
protected boolean |
isSelected(IModel<?> model)
Does the given model contain a selected value.
|
void |
updateModel()
Updates this components model from the request, it expects that the object is already
converted through the convertInput() call that is called by the validate() method when a form
is being processed.
|
add, add, checkRequired, clearInput, convertValue, error, getConvertedInput, getDefaultLabel, getDefaultLabel, getForm, getInput, getInputAsArray, getInputName, getModel, getModelObject, getParameterValues, 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, setType, shouldTrimInput, trim, updateAutoLabels, updateCollectionModel, valid, validate, validateRequired, validateValidators, visitComponentsPostOrder, visitFormComponentsPostOrder
getLabel
getWebApplication, getWebPage, getWebRequest, getWebResponse, getWebSession
add, addDequeuedComponent, addOrReplace, autoAdd, canDequeueTag, contains, dequeue, dequeue, dequeuePreamble, findChildComponent, findComponentToDequeue, get, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getMarkupType, getRegionMarkup, internalAdd, internalInitialize, iterator, iterator, newDequeueContext, onAfterRenderChildren, onComponentTagBody, 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, createConverter, debug, detach, detachModel, 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, isRendering, 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 Select(String id)
id
- component idpublic Select(String id, IModel<T> model)
id
- model
- WebMarkupContainer.WebMarkupContainer(String, IModel)
protected String getModelValue()
getModelValue
in class FormComponent<T>
public void convertInput()
FormComponent
FormComponent.getType()
and records any thrown ConversionException
s.
Converted value is available through FormComponent.getConvertedInput()
.
Usually the user should do custom conversions by specifying an IConverter
by
registering it with the application by overriding Application.getConverterLocator()
,
or at the component level by overriding Component.getConverter(Class)
.
public void updateModel()
FormComponent
setModelObject(getConvertedInput());DO NOT CALL THIS METHOD DIRECTLY UNLESS YOU ARE SURE WHAT YOU ARE DOING. USUALLY UPDATING YOUR MODEL IS HANDLED BY THE FORM, NOT DIRECTLY BY YOU.
updateModel
in interface IFormModelUpdateListener
updateModel
in class FormComponent<T>
FormComponent.updateModel()
protected boolean isSelected(IModel<?> model)
model
- model to test on selectionCopyright © 2006–2021 Apache Software Foundation. All rights reserved.