Class Selectize

    • Constructor Detail

      • Selectize

        public Selectize​(String id)
      • Selectize

        public Selectize​(String id,
                         IModel<?> options)
        Creates a selectize component
        Parameters:
        id - the id of the component
        options - the options. If the model object value is instanceof String a tag representation is chosen. If the model object is instance of SelectizeOption a 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 component
        optionGroups - the selectize groups, used for a select representation
        options - the selectize options, used for the selection in the select representation
    • Method Detail

      • extendConfig

        protected com.github.openjson.JSONObject extendConfig​(com.github.openjson.JSONObject config)
      • setDelimiter

        public void setDelimiter​(String delimiter)
        Sets the delimiter (default is ",")
        Parameters:
        delimiter - the delimiter to be used
      • 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 ensure enableAjaxHandling() 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 ensure enableAjaxHandling() 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 changes
        value - 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