org.wicketstuff.select2
Class TextChoiceProvider<T>
java.lang.Object
org.wicketstuff.select2.ChoiceProvider<T>
org.wicketstuff.select2.TextChoiceProvider<T>
- Type Parameters:
T - type of choice object
- All Implemented Interfaces:
- Serializable, org.apache.wicket.model.IDetachable, org.apache.wicket.util.io.IClusterable
- Direct Known Subclasses:
- StringTextChoiceProvider
public abstract class TextChoiceProvider<T>
- extends ChoiceProvider<T>
Takes care of Json serialization for the most common usecase where each choice is rendered as a
text string.
- Author:
- igor
- See Also:
- Serialized Form
|
Method Summary |
protected abstract String |
getDisplayText(T choice)
|
protected abstract Object |
getId(T choice)
|
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 |
TextChoiceProvider
public TextChoiceProvider()
getDisplayText
protected abstract String getDisplayText(T choice)
getId
protected abstract Object getId(T choice)
toJson
public final void toJson(T choice,
org.apache.wicket.ajax.json.JSONStringer writer)
throws org.apache.wicket.ajax.json.JSONException
- Description copied from class:
ChoiceProvider
- Converts the specified choice to Json.
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());
}
- Specified by:
toJson in class ChoiceProvider<T>
- Parameters:
choice - choice to convertwriter - Json writer that should be used to covnert the choice
- Throws:
org.apache.wicket.ajax.json.JSONException
Copyright © 2018. All rights reserved.