T - type of choice objectM - type of model objectpublic abstract class AbstractSelect2Choice<T,M> extends FormComponent<M> implements IRequestListener
FLAG_CONVERT_EMPTY_INPUT_STRING_TO_NULL, VALUE_SEPARATORENABLE, FLAG_INITIALIZED, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER, RFLAG_CONTAINER_DEQUEING| Constructor and Description |
|---|
AbstractSelect2Choice(String id) |
AbstractSelect2Choice(String id,
ChoiceProvider<T> provider)
Constructor.
|
AbstractSelect2Choice(String id,
IModel<M> model)
Constructor
|
AbstractSelect2Choice(String id,
IModel<M> model,
ChoiceProvider<T> provider)
Construct.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
appendOptionHtml(AppendingStringBuffer buffer,
T choice)
Append a single option markup.
|
protected Collection<T> |
convertIdsToChoices(List<String> ids)
Convert IDS into choices.
|
void |
convertInput() |
protected abstract CharSequence |
createOptionsHtml(M currentValue)
Creates the HTML option(s) markup representing the current value.
|
static <T> void |
generateJSON(ChoiceProvider<T> provider,
OutputStream outputStream)
Utility method to generate JSON response.
|
static <T> void |
generateJSON(String queryParam,
ChoiceProvider<T> provider,
OutputStream outputStream)
Utility method to generate JSON response.
|
protected M |
getCurrentValue() |
protected String |
getEscapedJsString(String key)
Escapes single quotes in localized strings to be used as JavaScript strings enclosed in
single quotes
|
protected String |
getJquerySafeMarkupId()
Gets the markup id that is safe to use in jQuery by escaping dots in the default
Component.getMarkup() |
ChoiceProvider<T> |
getProvider() |
Settings |
getSettings() |
protected boolean |
getStatelessHint() |
boolean |
isAjax() |
boolean |
isInputNullable()
Empty input is acceptable
|
protected void |
onComponentTag(ComponentTag tag)
Processes the component tag.
|
void |
onComponentTagBody(MarkupStream markupStream,
ComponentTag openTag)
this method will add default options
|
protected void |
onConfigure() |
protected void |
onDetach() |
void |
onEvent(IEvent<?> event) |
protected void |
onInitialize() |
void |
onRequest() |
void |
setProvider(ChoiceProvider<T> provider)
Sets the choice provider
|
add, add, checkRequired, clearInput, convertValue, error, getConvertedInput, getDefaultLabel, getDefaultLabel, getForm, getInput, getInputAsArray, getInputName, getModelValue, getParameterValues, getRawInput, getType, getValidatorKeyPrefix, getValidators, getValue, hasRawInput, inputAsInt, inputAsInt, inputAsIntArray, inputChanged, internalOnModelChanged, invalid, isMultiPart, isRequired, isValid, newValidatable, newValidationError, onDisabled, onInvalid, onRequired, onValid, processChildren, processInput, remove, reportRequiredError, setConvertedInput, setLabel, setModelValue, setRequired, setType, shouldTrimInput, trim, updateAutoLabels, updateCollectionModel, updateModel, valid, validate, validateRequired, validateValidators, visitComponentsPostOrder, visitFormComponentsPostOrdergetLabelgetWebApplication, getWebPage, getWebRequest, getWebResponse, getWebSessionadd, addDequeuedComponent, addOrReplace, autoAdd, canDequeueTag, contains, dequeue, dequeue, dequeuePreamble, findChildComponent, findComponentToDequeue, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getMarkupType, getRegionMarkup, internalAdd, internalInitialize, iterator, iterator, newDequeueContext, onRender, queue, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderNext, replace, setDefaultModel, size, stream, streamChildren, toString, toString, visitChildren, visitChildrenadd, addStateChange, beforeRender, canCallListener, canCallListenerAfterExpiry, 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, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalRenderComponent, internalRenderHead, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isInitialized, isRenderAllowed, isRendering, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, newMarkupSourcingStrategy, onAfterRender, onBeforeRender, onModelChanged, onModelChanging, onReAdd, onRemove, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, renderHead, renderPart, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, send, setAuto, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setIgnoreAttributeModifier, setMarkup, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setParent, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, success, urlFor, urlFor, urlFor, urlForListener, urlForListener, visitParents, visitParents, warn, wrapclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitrendersPagegetDefaultModel, getDefaultModelObject, getModel, getModelObject, setDefaultModel, setDefaultModelObject, setModel, setModelObjectforEach, spliteratorpublic AbstractSelect2Choice(String id)
id - markup idpublic AbstractSelect2Choice(String id, IModel<M> model)
id - component idmodel - component modelpublic AbstractSelect2Choice(String id, ChoiceProvider<T> provider)
id - component idprovider - choice providerpublic AbstractSelect2Choice(String id, IModel<M> model, ChoiceProvider<T> provider)
id - markup idmodel - model for selectprovider - choice providerpublic final Settings getSettings()
public final void setProvider(ChoiceProvider<T> provider)
provider - provider to setpublic final ChoiceProvider<T> getProvider()
public final void convertInput()
convertInput in class FormComponent<M>protected final Collection<T> convertIdsToChoices(List<String> ids)
ids - list of identitiesprotected String getJquerySafeMarkupId()
Component.getMarkup()protected String getEscapedJsString(String key)
key - resource key for localized messageprotected final M getCurrentValue()
protected void onInitialize()
onInitialize in class MarkupContainerprotected void onConfigure()
onConfigure in class Componentpublic void onEvent(IEvent<?> event)
onEvent in interface IEventSinkonEvent in class Componentprotected boolean getStatelessHint()
getStatelessHint in class Componentpublic boolean isAjax()
public static <T> void generateJSON(ChoiceProvider<T> provider, OutputStream outputStream)
provider - outputStream - public static <T> void generateJSON(String queryParam, ChoiceProvider<T> provider, OutputStream outputStream)
provider - outputStream - queryParam - - parameter to be used as Ajax query parampublic void onRequest()
onRequest in interface IRequestListenerprotected void onDetach()
onDetach in class FormComponent<M>protected void appendOptionHtml(AppendingStringBuffer buffer, T choice)
buffer - buffer to append tochoice - choice to create option markup forprotected void onComponentTag(ComponentTag tag)
onComponentTag in class FormComponent<M>tag - Tag to modifyComponent.onComponentTag(ComponentTag)public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag)
onComponentTagBody in class MarkupContainermarkupStream - The markup streamopenTag - The open tag for the bodyprotected abstract CharSequence createOptionsHtml(M currentValue)
currentValue - the current valuepublic boolean isInputNullable()
isInputNullable in class FormComponent<M>Copyright © 2020. All rights reserved.