Package org.wicketstuff.selectize
Class Selectize
- All Implemented Interfaces:
Serializable,Iterable,IEventSink,IEventSource,IFeedbackContributor,IConverterLocator,IGenericComponent,IMetadataContext,IFormModelUpdateListener,IFormVisitorParticipant,ILabelProvider,IHeaderContributor,IRequestableComponent,IHierarchical,IClusterable
Used to create a selectize.js choice component
- Author:
- Tobias Soloschenko
- See Also:
-
Field Summary
FieldsFields inherited from class org.apache.wicket.markup.html.form.FormComponent
FLAG_CONVERT_EMPTY_INPUT_STRING_TO_NULL, VALUE_SEPARATORFields 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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidUsed to enable AJAX handling.protected com.github.openjson.JSONObjectextendConfig(com.github.openjson.JSONObject config) booleanIf 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 voidvoidrenderHead(IHeaderResponse response) Renders the required javascript / css librariesprotected SelectizeResponseProvides the response and data for AJAX calls.protected ComponentProvides 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 entriessetDefaultModel(IModel model) voidsetDelimiter(String delimiter) Sets the delimiter (default is ",")voidsetPlaceholder(String placeholder) Sets the placeholdervoidSets the theme of the selectize componentMethods 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, visitFormComponentsPostOrderMethods inherited from class org.apache.wicket.markup.html.form.LabeledWebMarkupContainer
getLabelMethods inherited from class org.apache.wicket.markup.html.WebMarkupContainer
getWebApplication, getWebPage, getWebRequest, getWebResponse, getWebSessionMethods 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, visitChildrenMethods 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, wrapMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.wicket.IGenericComponent
getDefaultModel, getDefaultModelObject, getModel, getModelObject, setDefaultModelObject, setModel, setModelObjectMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
SELECTIZE_COMPONENT_ID
- See Also:
-
-
Constructor Details
-
Selectize
-
Selectize
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 Details
-
renderHead
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
- Overrides:
onComponentTagin classFormComponent
-
setDelimiter
Sets the delimiter (default is ",")- Parameters:
delimiter- the delimiter to be used
-
setTheme
Sets the theme of the selectize component- Parameters:
theme- the theme
-
setPlaceholder
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
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
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
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
- Specified by:
setDefaultModelin interfaceIGenericComponent- Overrides:
setDefaultModelin classMarkupContainer
-