here is the version that stores the id in the model instead...maybe at some point it can make its way into extensions or core
import java.util.List; import org.apache.wicket.markup.html.form.DropDownChoice; import org.apache.wicket.markup.html.form.IChoiceRenderer; import org.apache.wicket.model.IModel; public class DropDownIdChoice extends DropDownChoice { public DropDownIdChoice(String id, IModel model, IModel choices, IChoiceRenderer renderer, Class<?> type) { super(id, model, choices, renderer); setType(type); } @Override public String getModelValue() { final Object id = getModelObject(); if (id != null) { return getConverter(getType()).convertToString(id, getLocale()); } else { return NO_SELECTION_VALUE; } } } -igor On Dec 11, 2007 9:58 AM, Ivaylo Kovatchev <[EMAIL PROTECTED]> wrote: > > Fair question. Why return the Id, instead of just using a Property model to > bind the member field of an object to a child component's model? > > Thanks for your insight. > > Yevgeni: If you do that you will have to have an object (can be the same one > that extends DropDownChoice) implement IChoiceRenderer, so that you can see > the field you are interested in on the dropdown. And also do not forget to > say > setChoiceRenderer(this); > In the constructor. > > > Johan Compagner wrote: > > > > yes this is true, you have to have a selected object that comes from the > > choices > > Why is this so hard to understand? I find that completely logical. > > > > Maybe with generics (1.4) this will be more clear > > > > * > > > > public* DropDownChoice(String id, IModel<T> model, IModel<List<T>> > > choices, > > IChoiceRenderer<T> renderer) > > > > So if your model object ins an integer, Then you also have to have a List > > of > > integers.. > > > > Are you guys working with pojos like: Person.getAddressId() instead of > > Person.getAddress() ?? > > > > johan > > On Dec 11, 2007 5:05 PM, Ivaylo Kovatchev <[EMAIL PROTECTED]> > > wrote: > > > > -- > View this message in context: > http://www.nabble.com/dropdownchoice-tp14233301p14279580.html > Sent from the Wicket - User mailing list archive at Nabble.com. > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]