Great input and you're forgiven for jumping the gun with SelectOption
;-)

I didn't even know there was a wicket SelectOption, which puts a new
spin on things. Regarding the conversion back to the model: Yes, I was
following the example hoping IT WOULD BE CORRECT.

I concur with you that it's probably trying to cast SelectOption into an
Integer, but that doesn't explain why it actually works when I refrain
from tagging a non-integer string to the label (e.g. '1' as the label
vs. '1 guest'). How does it manage to convert properly then?

Michael

-----Original Message-----
From: John Krasnay [mailto:[EMAIL PROTECTED] 
Sent: Friday, May 09, 2008 9:02 AM
To: [email protected]
Subject: Re: DropDownChoice throws IllegalArgumentException with Integer
values

On Fri, May 09, 2008 at 11:53:30AM -0400, John Krasnay wrote:
> On Fri, May 09, 2008 at 08:25:05AM -0700, Michael Mehrle wrote:
> > Anyone? Was hoping for some input here ;-)
> > 
> >
http://cwiki.apache.org/WICKET/another-dropdownchoice-example-by-adam.ht
> > ml
> > 
> > The only change I made to SelectOption is to set the 'value' field
to an
> > Integer (which I need for my model).
> > 
> 
> That example is terrible. SelectOption is a Wicket component and an
> internal implementation detail of DropDownChoice. It should not be in
> your business model as the example shows.
> 
> If you're setting an integer property via a DropDownChoice, you should
> pass a List<Integer> and implement ChoiceRenderer.getDisplayValue() to
> output the right string to display.
> 
> My wild-ass guess would be that Wicket is trying to cast a
SelectOption
> into an Integer, with predictable results.
> 
> jk

Ugh, I just noticed that the example has its own SelectOption class, not
the one from Wicket. But I stand by the "golden rule" of DropDownChoice:
always pass a list of the same type of object that you expect to receive
back in your business model.

jk

---------------------------------------------------------------------
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]

Reply via email to