On Fri, 28 Oct 2005 01:39:54 -0700, Johan Compagner <[EMAIL PROTECTED]> wrote:

this looks like the most commor error people are making with this.
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.

Thanks for the reply.

In my first post, I had a couple of issues, and I don't want to lose sight of the other, because it is actually a bigger problem. That is in the case that I do just use a simple list of strings, like this:

new DropDownChoice("id", LIST_OF_STRINGS);

I don't get any default values (either "Choose One" or from my properties file), instead the default selected value is the first in the list. If I do this:

new DropDownChoice("id", new Model(), LIST_OF_STRINGS)

I get the a default value, but it will always be marked as selected in the html, in addition to whatever is actually selected, so what is actually selected is never persisted to the object model.

About ChoiceRenderer:

The case above with display value the same as id value - I need to be able to have them be different in other cases.

I do remeber seeing something about the selected object being of the same type, and I tested that, and it seemed to work, but I need to persist just the code String into the model, not the USState object.

Perhaps I don't understand the intended usage here.

It seems like the type of thing I want to do must be fairly common. Say I want to list US States by full name, but persist the abbreviation (code) in my model. A map of Strings in the front end (display, value) to a String in the model (value). Is there a simple way to do this?


-------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to