|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.wicket.markup.html.form.ChoiceRenderer<T>
T
- The model object typepublic class ChoiceRenderer<T>
Default implementation of IChoiceRenderer
. Usage:
new DropDownChoice<User>("users", new Model<User>(selectedUser), listOfUsers)creates a DropDownChoice of users and the display value will be toString() and the id the index of the object in the ListOfUsers.
new DropDownChoice<User>("users", new Model<User>(selectedUser), listOfUsers, new ChoiceRenderer<User>("name"))creates a DropDownChoice of users and the display value will be looked up by property expression ("name") and the id the index of the object in the ListOfUsers
new DropDownChoice<User>("users", new Model<User>(selectedUser), listOfUsers, new ChoiceRenderer<User>("name", "id"))creates a DropDownChoice of users and the display value will be looked up by property expression ("name") and the id will be looked up by the property expression "id"
Constructor Summary | |
---|---|
ChoiceRenderer()
Construct. |
|
ChoiceRenderer(String displayExpression)
Construct. |
|
ChoiceRenderer(String displayExpression,
String idExpression)
Construct. |
Method Summary | |
---|---|
Object |
getDisplayValue(T object)
Get the value for displaying to an end user. |
String |
getIdValue(T object,
int index)
This method is called to get the id value of an object (used as the value attribute of a choice element) The id can be extracted from the object like a primary key, or if the list is stable you could just return a toString of the index. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ChoiceRenderer()
public ChoiceRenderer(String displayExpression)
displayExpression
- A property expression to get the display valuepublic ChoiceRenderer(String displayExpression, String idExpression)
displayExpression
- A property expression to get the display valueidExpression
- A property expression to get the id valueMethod Detail |
---|
public Object getDisplayValue(T object)
IChoiceRenderer
getDisplayValue
in interface IChoiceRenderer<T>
object
- the actual object
IChoiceRenderer.getDisplayValue(java.lang.Object)
public String getIdValue(T object, int index)
IChoiceRenderer
Note that the given index can be -1
if the object in question is not contained in the
available choices.
getIdValue
in interface IChoiceRenderer<T>
object
- The object for which the id should be generatedindex
- The index of the object in the choices list.
IChoiceRenderer.getIdValue(java.lang.Object, int)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |