The thing that makes your example awkward (IMHO, of course) is that it
leaves out how the value that the user selects makes its way back into
the app's domain object. The OP said he wants "my model updates with 1,
2, and 3." From that I understand he has some object with an int
property...

class Widget {
    private int type;
    //...
}

Widget myWidget;

To complete your example, you would have to do the following when the
component was initialized:

- create a variable of type Choice to hold the selection
- loop through the list of choices, finding the one that matches
  myWidget.type and storing it in the variable
- pass a PropertyModel to the DDC pointing to the choice variable

Then, when the form is submitted, the Choice variable would contain a
(possibly different) Choice object, corresponding to the one the user
selected. You would then have to set myWidget.type from the id property
of your choice variable.

In my example, this is all done automatically, since the PropertyModel
points directly to the property to be updated. But this is only possible
if you give DDC a list of objects of the same type as the property.

jk


On Mon, Jul 27, 2009 at 05:13:05PM -0700, Mathias Nilsson wrote:
> 
> Wasn't this more awkward?
> 
> -- 
> View this message in context: 
> http://www.nabble.com/DropDownChoice-with-ID-and-Value-tp24686742p24690478.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to