T
- public abstract class AbstractAutoCompleteRenderer<T> extends Object implements IAutoCompleteRenderer<T>
Constructor and Description |
---|
AbstractAutoCompleteRenderer() |
Modifier and Type | Method and Description |
---|---|
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).
|
protected abstract String |
getTextValue(T object)
Retrieves the text value that will be set on the textbox if this assist is selected
|
void |
render(T object,
Response response,
String criteria)
Render the html fragment for the given completion object.
|
protected abstract void |
renderChoice(T object,
Response response,
String criteria)
Render the visual portion of the assist.
|
void |
renderFooter(Response response,
int count)
Render the html footer fragment for the completion.
|
void |
renderHeader(Response response)
Render the html header fragment for the completion.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
detach
public void render(T object, Response response, String criteria)
IAutoCompleteRenderer
Response.write(CharSequence)
.render
in interface IAutoCompleteRenderer<T>
object
- completion choice objectresponse
- response objectcriteria
- text entered by user so farpublic void renderHeader(Response response)
IAutoCompleteRenderer
Response.write(CharSequence)
.renderHeader
in interface IAutoCompleteRenderer<T>
public void renderFooter(Response response, int count)
IAutoCompleteRenderer
Response.write(CharSequence)
.renderFooter
in interface IAutoCompleteRenderer<T>
count
- The number of choices renderedprotected abstract void renderChoice(T object, Response response, String criteria)
Response.write(CharSequence)
object
- current assist choiceresponse
- criteria
- protected abstract String getTextValue(T object)
object
- assist choice objectprotected CharSequence getOnSelectJavaScriptExpression(T item)
null
the chosen text value will be ignored.
example 1:
protected CharSequence getOnSelectJavaScript(Address address) { final StringBuilder js = new StringBuilder(); js.append("wicketGet('street').value ='" + address.getStreet() + "';"); js.append("wicketGet('zipcode').value ='" + address.getZipCode() + "';"); js.append("wicketGet('city').value ='" + address.getCity() + "';"); js.append("input"); // <-- 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.
item
- the autocomplete item to get a custom javascript expression fornull
if default behavior is
intentedCopyright © 2006–2022 Apache Software Foundation. All rights reserved.