I think you should have your own implementation of the choice renderer for this, and should override the getDisplayValue method.
something like
public String getDisplayValue(Object object)
{
    USState state = (USState )object
    return state.getCode();
}

and add tthe drop down as
new DropDownChoice("id", Lsit of State Objects, new YourRenderer());

hope this helps

Cheers
Dipu


----- Original Message ----- From: "David Ruberg" <[EMAIL PROTECTED]>
To: <wicket-user@lists.sourceforge.net>
Sent: Friday, October 28, 2005 7:34 AM
Subject: [Wicket-user] DropDownChoice and RadioChoice


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




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

Reply via email to