You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Ivan Dudko <iv...@gmail.com> on 2010/03/21 09:09:53 UTC

DropDownChoice and Null value

Hello!

I am trying to use DropDownChoice.
The first problem is no null value in DropDownChoice... (I must add null
value to choices array????) How i can do this in right way?

And second problem is i can't understand why if i add
System.out.println in getIdValue method it calls twice for each ID?

This is my code:

final ArrayList<Object> typeList = typeDAO.getData();
        DropDownChoice<Object> ddcType = new
DropDownChoice<Object>("typeid", typeList, new IChoiceRenderer<Object>() {

private static final long serialVersionUID = 1L;
public Object getDisplayValue(Object object) {
Map<?,?> map = (Map<?,?>) object;
return map.get("Name");
}
public String getIdValue(Object object, int index) {
if (object instanceof HashMap<?,?>) {
//System.out.println("Test="+map.get("ID").toString());
Map<?,?> map = (Map<?,?>) object;
return map.get("ID").toString();
}
return object.toString();
}
        });
form.add(ddcType.setType(Integer.class));



Thank you.

Best regards,
Ivan Dudko