org.wicketstuff.select2
Class Select2MultiChoice<T>

java.lang.Object
  extended by org.apache.wicket.Component
      extended by org.apache.wicket.MarkupContainer
          extended by org.apache.wicket.markup.html.WebMarkupContainer
              extended by org.apache.wicket.markup.html.form.LabeledWebMarkupContainer
                  extended by org.apache.wicket.markup.html.form.FormComponent<T>
                      extended by org.apache.wicket.markup.html.form.AbstractTextComponent<T>
                          extended by org.apache.wicket.markup.html.form.TextField<T>
                              extended by org.apache.wicket.markup.html.form.HiddenField<M>
                                  extended by org.wicketstuff.select2.Select2MultiChoice<T>
Type Parameters:
T - type of choice object
All Implemented Interfaces:
Serializable, Iterable<org.apache.wicket.Component>, org.apache.wicket.event.IEventSink, org.apache.wicket.event.IEventSource, org.apache.wicket.IConverterLocator, org.apache.wicket.IGenericComponent<Collection<T>>, org.apache.wicket.IRequestListener, org.apache.wicket.IResourceListener, org.apache.wicket.markup.html.form.IFormModelUpdateListener, org.apache.wicket.markup.html.form.IFormVisitorParticipant, org.apache.wicket.markup.html.form.ILabelProvider<String>, org.apache.wicket.markup.html.IHeaderContributor, org.apache.wicket.request.component.IRequestableComponent, org.apache.wicket.util.IHierarchical<org.apache.wicket.Component>, org.apache.wicket.util.io.IClusterable

public class Select2MultiChoice<T>
extends org.apache.wicket.markup.html.form.HiddenField<M>

Multi-select Select2 component. Should be attached to a <input type='hidden'/> element.

Author:
igor
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.wicket.markup.html.form.AbstractTextComponent
org.apache.wicket.markup.html.form.AbstractTextComponent.ITextFormatProvider
 
Field Summary
 
Fields inherited from class org.apache.wicket.markup.html.form.FormComponent
FLAG_CONVERT_EMPTY_INPUT_STRING_TO_NULL, VALUE_SEPARATOR
 
Fields inherited from class org.apache.wicket.Component
ENABLE, FLAG_INITIALIZED, FLAG_REMOVING_FROM_HIERARCHY, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER
 
Fields inherited from interface org.apache.wicket.IResourceListener
INTERFACE
 
Constructor Summary
Select2MultiChoice(String id)
           
Select2MultiChoice(String id, org.apache.wicket.model.IModel<Collection<T>> model)
           
Select2MultiChoice(String id, org.apache.wicket.model.IModel<Collection<T>> model, ChoiceProvider<T> provider)
           
 
Method Summary
protected  Collection<T> convertIdsToChoices(List<String> ids)
          Convert IDS into choices.
protected  void convertInput()
           
protected  Collection<T> convertValue(String[] value)
           
protected  M getCurrentValue()
           
protected  String getEscapedJsString(String key)
          Escapes single quotes in localized strings to be used as JavaScript strings enclosed in single quotes
 String[] getInputAsArray()
           
protected  String getJquerySafeMarkupId()
          Gets the markup id that is safe to use in jQuery by escaping dots in the default Component.getMarkup()
protected  String getModelValue()
           
 ChoiceProvider<T> getProvider()
           
 Settings getSettings()
           
protected  void onConfigure()
           
protected  void onDetach()
           
 void onEvent(org.apache.wicket.event.IEvent<?> event)
           
protected  void onInitialize()
           
 void onResourceRequested()
           
 void renderHead(org.apache.wicket.markup.head.IHeaderResponse response)
           
protected  void renderInitializationScript(org.apache.wicket.markup.head.IHeaderResponse response)
          Renders script used to initialize the value of Select2 after it is created so it matches the current model object.
 void setProvider(ChoiceProvider<T> provider)
          Sets the choice provider
 void updateModel()
           
 
Methods inherited from class org.apache.wicket.markup.html.form.HiddenField
getInputType
 
Methods inherited from class org.apache.wicket.markup.html.form.TextField
onComponentTag
 
Methods inherited from class org.apache.wicket.markup.html.form.AbstractTextComponent
getConvertEmptyInputStringToNull, isInputNullable, onBeforeRender, setConvertEmptyInputStringToNull
 
Methods inherited from class org.apache.wicket.markup.html.form.FormComponent
add, add, checkRequired, clearInput, error, getConvertedInput, getDefaultLabel, getDefaultLabel, getForm, getInput, getInputName, getModel, getModelObject, 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, setModel, setModelObject, setModelValue, setRequired, setType, shouldTrimInput, trim, updateAutoLabels, updateCollectionModel, valid, validate, validateRequired, validateValidators, visitComponentsPostOrder, visitFormComponentsPostOrder
 
Methods inherited from class org.apache.wicket.markup.html.form.LabeledWebMarkupContainer
getLabel
 
Methods inherited from class org.apache.wicket.markup.html.WebMarkupContainer
getWebApplication, getWebPage, getWebRequest, getWebResponse, getWebSession
 
Methods inherited from class org.apache.wicket.MarkupContainer
add, addOrReplace, autoAdd, contains, get, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getMarkupType, internalAdd, internalInitialize, iterator, iterator, onAfterRenderChildren, onComponentTagBody, onRender, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderNext, replace, setDefaultModel, size, swap, toString, toString, visitChildren, visitChildren, visitChildren, visitChildren
 
Methods inherited from class org.apache.wicket.Component
add, addStateChange, afterRender, beforeRender, canCallListenerInterface, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, clearOriginalDestination, configure, continueToOriginalDestination, 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, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isRenderAllowed, isRendering, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, newMarkupSourcingStrategy, onAfterRender, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Select2MultiChoice

public Select2MultiChoice(String id,
                          org.apache.wicket.model.IModel<Collection<T>> model,
                          ChoiceProvider<T> provider)

Select2MultiChoice

public Select2MultiChoice(String id,
                          org.apache.wicket.model.IModel<Collection<T>> model)

Select2MultiChoice

public Select2MultiChoice(String id)
Method Detail

getInputAsArray

public final String[] getInputAsArray()
Overrides:
getInputAsArray in class org.apache.wicket.markup.html.form.FormComponent<Collection<T>>

updateModel

public void updateModel()
Specified by:
updateModel in interface org.apache.wicket.markup.html.form.IFormModelUpdateListener
Overrides:
updateModel in class org.apache.wicket.markup.html.form.FormComponent<Collection<T>>

convertValue

protected final Collection<T> convertValue(String[] value)
                                    throws org.apache.wicket.util.convert.ConversionException
Overrides:
convertValue in class org.apache.wicket.markup.html.form.FormComponent<Collection<T>>
Throws:
org.apache.wicket.util.convert.ConversionException

onInitialize

protected void onInitialize()

getModelValue

protected String getModelValue()
Overrides:
getModelValue in class org.apache.wicket.markup.html.form.FormComponent<Collection<T>>

renderInitializationScript

protected void renderInitializationScript(org.apache.wicket.markup.head.IHeaderResponse response)
Renders script used to initialize the value of Select2 after it is created so it matches the current model object.

Parameters:
response - header response

getSettings

public final Settings getSettings()
Returns:
Select2 settings for this component

setProvider

public final void setProvider(ChoiceProvider<T> provider)
Sets the choice provider

Parameters:
provider -

getProvider

public final ChoiceProvider<T> getProvider()
Returns:
choice provider

convertInput

protected final void convertInput()
Overrides:
convertInput in class org.apache.wicket.markup.html.form.AbstractTextComponent<M>

convertIdsToChoices

protected final Collection<T> convertIdsToChoices(List<String> ids)
Convert IDS into choices.

Parameters:
ids - list of identities
Returns:
collection of choices or empty collection

getJquerySafeMarkupId

protected String getJquerySafeMarkupId()
Gets the markup id that is safe to use in jQuery by escaping dots in the default Component.getMarkup()

Returns:
markup id

getEscapedJsString

protected String getEscapedJsString(String key)
Escapes single quotes in localized strings to be used as JavaScript strings enclosed in single quotes

Parameters:
key - resource key for localized message
Returns:
localized string with escaped single quotes

renderHead

public void renderHead(org.apache.wicket.markup.head.IHeaderResponse response)
Specified by:
renderHead in interface org.apache.wicket.markup.html.IHeaderContributor
Overrides:
renderHead in class org.apache.wicket.Component

getCurrentValue

protected final M getCurrentValue()
Returns:
current value, suitable for rendering as selected value in select2 component

onConfigure

protected void onConfigure()
Overrides:
onConfigure in class org.apache.wicket.Component

onEvent

public void onEvent(org.apache.wicket.event.IEvent<?> event)
Specified by:
onEvent in interface org.apache.wicket.event.IEventSink
Overrides:
onEvent in class org.apache.wicket.Component

onResourceRequested

public void onResourceRequested()
Specified by:
onResourceRequested in interface org.apache.wicket.IResourceListener

onDetach

protected void onDetach()
Overrides:
onDetach in class org.apache.wicket.markup.html.form.FormComponent<M>


Copyright © 2018. All rights reserved.