Show two fields in Wicket DropDownChoice via ChoiceRenderer

387 views Asked by At

In my DropDownChoice I want to show two fields: Name - Surname

DropDownChoice<Person> customer = new DropDownChoice<Person>(
                    "customer", new PropertyModel<Person>(customermodel, "customer"),list, new ChoiceRenderer<Person>("name", "id"));

How I can do that? Like: Peter - Griffin

1

There are 1 answers

0
Michael Zhavzharov On

You can just override getDisplayValue(Person object) method for ChoiceRender like this:

new ChoiceRenderer<Person>("name", "id")
{
    @Override
    public Object getDisplayValue(Person object)
    {
        //insert your logic for checking super.method emptiness and etc here.
        return super.getDisplayValue(object) + "-" + object.getSurname();
    }
}

Or just implement your own IChoiceRendererinterface.