Yeah, I can be thick headed at times ;-)

Actually the solution is to add some custom code to getIdValue(), not
getDisplayValue(). It's a bit of a hack, but seems to work fine now.
Next time I'll build this differently though, that's for sure.

Thank you for walking me through this. This whole thing was a bit
confusing to me, especially since that tutorial leads people in the
wrong direction. It makes complete sense that the model and list objects
need to be of the same type.

Best,

Michael

-----Original Message-----
From: John Krasnay [mailto:[EMAIL PROTECTED] 
Sent: Friday, May 09, 2008 7:13 PM
To: users@wicket.apache.org
Subject: Re: DropDownChoice throws IllegalArgumentException with Integer
values

On Fri, May 09, 2008 at 06:42:11PM -0700, Michael Mehrle wrote:
> Thanks for the input, John - but I the plot thickens here. It seems
that
> there is actually a Wicket bug that needs to get fixed. After a lot of
> tinkering I figured out why I was getting this error. The VERY FIRST
> TIME my renderer is being called it actually calls getIdValue() with
an
> Integer, not with the Object that I'm using. In my debugger I saw the

This isn't a bug. The integer is coming from your business model.
DropDownChoice calls getIdValue() with this value so it can pre-select
the correct option based on your current business object value.

I'll try explaining this again. Maybe this time it will click.

You give a DDC a model and a list of possible values. The type of object
returned by the model and the type of objects in the list *must* be the
same. You've already mentioned that your model returns an Integer, so
you *must* pass a list of Integers, not IntegerSelectChoice or anything
else.

If you want to display something different than the integer, you have to
implement some custom code in ChoiceRenderer.getDisplayValue(). Don't
get hung up on the idea that the value returned has to be a property of
the objects in your list. It can be anything, such as the
getString("period_" + object.toString()) in my example.

You are probably used to a Model2 framework like Struts, where you have
to create lists of key/value pair objects to render <select>s. No need
for such an artificial structure in Wicket.

Is the light coming on yet?

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