Package org.wicketstuff.selectize
Class Selectize
-
- All Implemented Interfaces:
Serializable,Iterable,IEventSink,IEventSource,IFeedbackContributor,IConverterLocator,IGenericComponent,IMetadataContext,IFormModelUpdateListener,IFormVisitorParticipant,ILabelProvider,IHeaderContributor,IRequestableComponent,IHierarchical,IClusterable
public class Selectize extends FormComponent
Used to create a selectize.js choice component- Author:
- Tobias Soloschenko
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringSELECTIZE_COMPONENT_ID-
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_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER, RFLAG_CONTAINER_DEQUEING, RFLAG_CONTAINER_HAS_REMOVALS
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidenableAjaxHandling()Used to enable AJAX handling.protected com.github.openjson.JSONObjectextendConfig(com.github.openjson.JSONObject config)booleanisCreateAvailable()If selectize is enabled to create entriesprotected voidonChange(AjaxRequestTarget target, String value)Is invoked when ever a user selected an option.
Important:This method is only invoked when ajax is enabledprotected voidonComponentTag(ComponentTag tag)voidrenderHead(IHeaderResponse response)Renders the required javascript / css librariesprotected SelectizeResponseresponse(String search)Provides the response and data for AJAX calls.protected ComponentresponseTemplate()Provides the template to be shown in the select result
Important: The item (SelectizeOption) to refer to is named item!
Important: The template uses handlebars template mechanism.voidsetCreateAvailable(boolean createAvailable)Set the selectize component to be enabled to create entriesMarkupContainersetDefaultModel(IModel model)voidsetDelimiter(String delimiter)Sets the delimiter (default is ",")voidsetPlaceholder(String placeholder)Sets the placeholdervoidsetTheme(SelectizeCssResourceReference.Theme theme)Sets the theme of the selectize component-
Methods inherited from class org.apache.wicket.markup.html.form.FormComponent
add, add, checkRequired, clearInput, convertInput, convertValue, error, getConvertedInput, getDefaultLabel, getDefaultLabel, getForm, getInput, getInputAsArray, getInputName, getModelValue, getParameterValues, getRawInput, getType, getValidatorKeyPrefix, getValidators, getValue, hasRawInput, inputAsInt, inputAsInt, inputAsIntArray, inputChanged, internalOnModelChanged, invalid, isInputNullable, isMultiPart, isRequired, isValid, newValidatable, newValidationError, onDetach, onDisabled, onInvalid, onValid, processChildren, processInput, remove, reportRequiredError, setConvertedInput, setLabel, setModelValue, setRequired, setType, shouldTrimInput, trim, updateAutoLabels, updateCollectionModel, updateModel, 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, addDequeuedComponent, addOrReplace, autoAdd, canDequeueTag, contains, dequeue, dequeue, dequeuePreamble, findChildComponent, findComponentToDequeue, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getMarkupType, getRegionMarkup, internalAdd, internalInitialize, iterator, iterator, newDequeueContext, onComponentTagBody, onInitialize, onRender, queue, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderNext, replace, size, stream, streamChildren, toString, toString, visitChildren, visitChildren
-
Methods inherited from class org.apache.wicket.Component
add, 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, getMarkupTag, 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, internalRenderComponent, internalRenderHead, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isInitialized, isRenderAllowed, isRendering, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, newMarkupSourcingStrategy, onAfterRender, onBeforeRender, onConfigure, onEvent, onModelChanged, onModelChanging, onReAdd, onRemove, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, 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, wrap
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.wicket.IGenericComponent
getDefaultModel, getDefaultModelObject, getModel, getModelObject, setDefaultModelObject, setModel, setModelObject
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
SELECTIZE_COMPONENT_ID
public static final String SELECTIZE_COMPONENT_ID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Selectize
public Selectize(String id)
-
Selectize
public Selectize(String id, IModel<?> options)
Creates a selectize component- Parameters:
id- the id of the componentoptions- the options. If the model object value is instanceofStringa tag representation is chosen. If the model object is instance ofSelectizeOptiona select representation is chosen.
-
Selectize
public Selectize(String id, IModel<Collection<SelectizeOptionGroup>> optionGroups, IModel<?> options)
Creates a selectize component- Parameters:
id- the id of the componentoptionGroups- the selectize groups, used for a select representationoptions- the selectize options, used for the selection in the select representation
-
-
Method Detail
-
renderHead
public void renderHead(IHeaderResponse response)
Renders the required javascript / css libraries- Specified by:
renderHeadin interfaceIHeaderContributor- Overrides:
renderHeadin classComponent
-
extendConfig
protected com.github.openjson.JSONObject extendConfig(com.github.openjson.JSONObject config)
-
onComponentTag
protected void onComponentTag(ComponentTag tag)
- Overrides:
onComponentTagin classFormComponent
-
setDelimiter
public void setDelimiter(String delimiter)
Sets the delimiter (default is ",")- Parameters:
delimiter- the delimiter to be used
-
setTheme
public void setTheme(SelectizeCssResourceReference.Theme theme)
Sets the theme of the selectize component- Parameters:
theme- the theme
-
setPlaceholder
public void setPlaceholder(String placeholder)
Sets the placeholder- Parameters:
placeholder- the placeholder to be used
-
enableAjaxHandling
public void enableAjaxHandling()
Used to enable AJAX handling. Please override the following methods to provide data
Method for response content:response(String)
Method for template how to display:responseTemplate()
-
response
protected SelectizeResponse response(String search)
Provides the response and data for AJAX calls. Please ensureenableAjaxHandling()is invoked when overriding this method- Parameters:
search- the search query parameter the user typed into the text field- Returns:
- the selectize response with a list of
SelectizeOption's custom values can be applied with selectizeOption.put("key","value");
-
responseTemplate
protected Component responseTemplate()
Provides the template to be shown in the select result
Important: The item (SelectizeOption) to refer to is named item!
Important: The template uses handlebars template mechanism. To display the "text" value of the SelectizeOption use the following syntax:<div>{{text}}<div>It is also important that you always use a <div> element in the response panel which can be used of selectize to apply the selected class.
Please ensureenableAjaxHandling()is invoked when overriding this method
- Returns:
- the Panel to be rendered in the template
-
onChange
protected void onChange(AjaxRequestTarget target, String value)
Is invoked when ever a user selected an option.
Important:This method is only invoked when ajax is enabled- Parameters:
target- the ajax request target to apply changesvalue- the selected value
-
isCreateAvailable
public boolean isCreateAvailable()
If selectize is enabled to create entries- Returns:
- if selectize is enabled to create entries
-
setCreateAvailable
public void setCreateAvailable(boolean createAvailable)
Set the selectize component to be enabled to create entries- Parameters:
createAvailable- if selectize is enabled to create entries
-
setDefaultModel
public MarkupContainer setDefaultModel(IModel model)
- Specified by:
setDefaultModelin interfaceIGenericComponent- Overrides:
setDefaultModelin classMarkupContainer
-
-