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,
org.apache.wicket.request.Response response,
String criteria)
Render the html fragment for the given completion object.
|
protected abstract void |
renderChoice(T object,
org.apache.wicket.request.Response response,
String criteria)
Render the visual portion of the assist.
|
void |
renderFooter(org.apache.wicket.request.Response response,
int count)
Render the html footer fragment for the completion.
|
void |
renderHeader(org.apache.wicket.request.Response response)
Render the html header fragment for the completion.
|
public void render(T object, org.apache.wicket.request.Response response, String criteria)
IAutoCompleteRendererResponse.write(CharSequence).render in interface IAutoCompleteRenderer<T>object - completion choice objectresponse - response objectcriteria - text entered by user so farpublic void renderHeader(org.apache.wicket.request.Response response)
IAutoCompleteRendererResponse.write(CharSequence).renderHeader in interface IAutoCompleteRenderer<T>public void renderFooter(org.apache.wicket.request.Response response, int count)
IAutoCompleteRendererResponse.write(CharSequence).renderFooter in interface IAutoCompleteRenderer<T>count - The number of choices renderedprotected abstract void renderChoice(T object, org.apache.wicket.request.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–2015 Apache Software Foundation. All rights reserved.