dropdown expects choice objects of type Short, you are giving it
SelectOption, it has trouble converting SelectOption to a Short.
three ways to do this. make your model expect a SelectOption object instead
of a short. ie add
User.setGender(SelectOption o) { gender=o.getGender(); }
two make your model convert on the fly
new ConvertingModel(new PropertyModel(user, "gender"));
three work with shorts and make your choice renderer translate the short
into the string. search the list for this, ive given this example before.
-igor
On 8/16/07, soulspirit <[EMAIL PROTECTED]> wrote:
>
>
> Hi everyone,
>
> I use this codesnippet for the <select wicket:id="gender"> tag in my
> markupfile:
>
> genderChoice = new DropDownChoice("gender", new PropertyModel(user,
> "gender", Short.class), Arrays.asList(genders), new ChoiceRenderer("key",
> "value"));
>
> when I submit the form i get following error:
> SelectOption[] genders = new SelectOption[]{new SelectOption("male", "1"),
> new SelectOption("female", "2")};
> wicket.util.convert.ConversionException: Cannot parse
> '[EMAIL PROTECTED]' using format
> [EMAIL PROTECTED]
> at
> wicket.util.convert.converters.AbstractConverter.newConversionException(
> AbstractConverter.java:72)
> at
> wicket.util.convert.converters.AbstractConverter.parse(
> AbstractConverter.java:52)
> at
> wicket.util.convert.converters.AbstractNumberConverter.parse(
> AbstractNumberConverter.java:69)
> at
> wicket.util.convert.converters.ShortConverter.convert(ShortConverter.java
> :44)
> at wicket.util.convert.Converter.convert(Converter.java:207)
> at
> wicket.util.lang.PropertyResolver$MethodGetAndSet.setValue(
> PropertyResolver.java:828)
> at
> wicket.util.lang.PropertyResolver$ObjectAndGetSetter.setValue(
> PropertyResolver.java:447)
> at
> wicket.util.lang.PropertyResolver.setValue(PropertyResolver.java:136)
> at
> wicket.model.AbstractPropertyModel.onSetObject(AbstractPropertyModel.java
> :182)
> at
> wicket.model.AbstractDetachableModel.setObject(
> AbstractDetachableModel.java:131)
> at wicket.Component.setModelObject(Component.java:2035)
> .....
>
>
> The SelectOption class looks like this:
> public class SelectOption implements Serializable {
> public SelectOption(String key, Short value) {
> this.key = key;
> this.value = value;
> }
>
> //getters and setters here.....
>
> private String key;
> private Short value;
> }
>
>
> I folowed this example:
>
> http://cwiki.apache.org/WICKET/dropdownchoice-examples.html#DropDownChoiceExamples-Customizingthedisplayofchoices
> .
>
>
> But things arnt working. Wicket doesnt pass the "value"-property to my
> user-object, but the whole SelectOption-object. Ive written a workaround
> (casting the passed Object to a SelectOption and reading the value with
> the
> getter) but this behavior seems strange to me...
> --
> View this message in context:
> http://www.nabble.com/ChoiceRenderer-issue-tf4280071.html#a12182692
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>