|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.wicketstuff.select2.ChoiceProvider<T>
T - type of choice objectpublic abstract class ChoiceProvider<T>
Acts as a bridge between Select2 components and the application's domain model.
The two important services provided by implementations are:
For the most common usecase where each choice is rendered as a text string see
TextChoiceProvider.
| Constructor Summary | |
|---|---|
ChoiceProvider()
|
|
| Method Summary | |
|---|---|
void |
detach()
|
abstract void |
query(String term,
int page,
Response<T> response)
Queries application for choices that match the search term and adds them to the
response |
abstract Collection<T> |
toChoices(Collection<String> ids)
Converts a list of choice ids back into application's choice objects. |
abstract void |
toJson(T choice,
org.apache.wicket.ajax.json.JSONStringer writer)
Converts the specified choice to Json. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ChoiceProvider()
| Method Detail |
|---|
public abstract void query(String term,
int page,
Response<T> response)
term and adds them to the
response
term - search termpage - requested search term results pageresponse - aggregate for matching choices as well as other response options
public abstract void toJson(T choice,
org.apache.wicket.ajax.json.JSONStringer writer)
throws org.apache.wicket.ajax.json.JSONException
At the very least each choice should contain an id attribute. If no custom rendering
function is specified, the text attribute should also be provided
Example: If mapping a User {Long id, String name} using default rendering the code should look like this:
toJson(User choice, JSONStringer writer)
{
writer.key("id").value(choice.getId()).key("text").value(choice.getName());
}
choice - choice to convertwriter - Json writer that should be used to covnert the choice
org.apache.wicket.ajax.json.JSONExceptionpublic abstract Collection<T> toChoices(Collection<String> ids)
ids collection will contain
exactly one id, and a collection containing exactly one choice should be returned.
ids - collection containing choice ids
public void detach()
detach in interface org.apache.wicket.model.IDetachable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||