Class AbstractAutoCompleteRenderer<T>

    • Method Detail

      • render

        public void render​(T object,
                           org.apache.wicket.request.Response response,
                           String criteria)
        Description copied from interface: IAutoCompleteRenderer
        Render the html fragment for the given completion object. Usually the html is written out by calling Response.write(CharSequence).
        Specified by:
        render in interface IAutoCompleteRenderer<T>
        Parameters:
        object - completion choice object
        response - response object
        criteria - text entered by user so far
      • renderHeader

        public void renderHeader​(org.apache.wicket.request.Response response)
        Description copied from interface: IAutoCompleteRenderer
        Render the html header fragment for the completion. Usually the html is written out by calling Response.write(CharSequence).
        Specified by:
        renderHeader in interface IAutoCompleteRenderer<T>
      • renderFooter

        public void renderFooter​(org.apache.wicket.request.Response response,
                                 int count)
        Description copied from interface: IAutoCompleteRenderer
        Render the html footer fragment for the completion. Usually the html is written out by calling Response.write(CharSequence).
        Specified by:
        renderFooter in interface IAutoCompleteRenderer<T>
        count - The number of choices rendered
      • renderChoice

        protected abstract void renderChoice​(T object,
                                             org.apache.wicket.request.Response response,
                                             String criteria)
        Render the visual portion of the assist. Usually the html representing the assist choice object is written out to the response use Response.write(CharSequence)
        Parameters:
        object - current assist choice
        response -
        criteria -
      • getTextValue

        protected abstract String getTextValue​(T object)
        Retrieves the text value that will be set on the textbox if this assist is selected
        Parameters:
        object - assist choice object
        Returns:
        the text value that will be set on the textbox if this assist is selected
      • getOnSelectJavaScriptExpression

        protected CharSequence getOnSelectJavaScriptExpression​(T item)
        Allows the execution of a custom javascript expression when an item is selected in the autocompleter popup (either by clicking on it or hitting enter on the current selection).

        The javascript to execute must be a javascript expression that will be processed using javascript's eval(). The function should return the textvalue to copy it into the corresponding form input field (the default behavior). the current text value will be in variable 'input'. If the function returns null the chosen text value will be ignored.

        example 1:

         protected CharSequence getOnSelectJavaScript(Address address)
         {
                final StringBuilder js = new StringBuilder();
                js.append("Wicket.DOM.get('street').value ='" + address.getStreet() + "';");
                js.append("Wicket.DOM.get('zipcode').value ='" + address.getZipCode() + "';");
                js.append("Wicket.DOM.get('city').value ='" + address.getCity() + "';");
                js.append("arguments[0]"); // <-- do not use return statement here!
                return js.toString();
         }
         
        example 2:
         protected CharSequence getOnSelectJavaScript(Currency currency)
         {
                final StringBuilder js = new StringBuilder();
                js.append("val rate = ajaxGetExchangeRateForCurrency(currencySymbol);");
                js.append("if(rate == null) alert('exchange rate service currently not available');");
                js.append("rate");
                return js.toString();
         }
         
        Then the autocompleter popup will be closed.
        Parameters:
        item - the autocomplete item to get a custom javascript expression for
        Returns:
        javascript to execute on selection or null if default behavior is intented