I will try to see if i can check this earlier and really throw a better error.
The problem looks like that youre Selected object is not the same as youre List obect
It has to be of the same type!
what is returned from USState.getStates()?
something like a State object yes?
With a code property?
So then the seleted value must also be a state object (and not the code property!!)
I youre selected value is the code property. Then you need to give the Choice a list of Codes.
(so not states)
i see that youre display value is the same as the id value (both are the code)
so you don't have to give a choicerender to the Choice constructor.
On 10/28/05, David Ruberg <[EMAIL PROTECTED]> wrote:
Hi All,
I'm using wicket for a project at work, and for the most part, I'm really
enjoying it. Thanks to everyone involved.
I'm having some problems with choices, though.
I'm using a BoundCompoundPropertyModel in a Form. I have a DropDownChoice
that is driven by a List of USState objects. These objects have a
getCode() method that provides the state abbreviation.
It seemed this was originally working:
new DropDownChoice("id", USState.getStates (), new ChoiceRenderer("code",
"code"));
but then I started getting an OGNL error about not finding
java.lang.String.code .
After doing some research, it seems that one of the ChoiceRenderer methods
(I can't remember which) is being called with a String instead of a
USState about one time in three.
So I changed the creation to this:
new DropDownChoice("id", new Model(), USState.getStates (), new
ChoiceRenderer("code", "code"));
This results in a default value that is always marked as selected in the
option list(in the html), in addition to any other selection that is
made. This causes the default selection to always be persisted.
I have some other DropDownChoices that are driven by String lists. In
these, if no new Model is given in the constructor, the default choice
does not show up ("Choose one", or from the properties file). If I
include a new Model, the default choice shows up, but again is always
selected, in addition to any other choice that is made.
I've tried this using RC1 and RC2.
If anyone can give me some insight here, I'd really appreciate it.
Also, a RequiredValidator attached to a RadioChoice seems to have no
effect in RC2, yet works fine for me in RC1.
Thanks again,
David Ruberg
-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user