Do you mean to manually iterate through the map and converting the string
keys
Wicket binds to enum keys? Even if I try to iterate through the map I get
the same ClassCastException.
Somehow Wicket managed to insert String as a key instead of enum.

Zbynek



On Mon, Feb 4, 2019 at 1:55 PM Francois Meillet <[email protected]>
wrote:

> use MyEnum.valueOf("your string ») before saving the data
>
> François
>
>
>
> > Le 4 févr. 2019 à 13:51, Zbynek Vavros <[email protected]> a écrit
> :
> >
> > I got this class that has map with enums as keys:
> >
> > public class MasterClass {
> >
> >    private Map<MyEnum, String> config = Maps.newHashMap();
> > }
> >
> > enum is classic:
> >
> > public enum MyEnum {
> >    VALUE1,
> >    VALUE2
> > }
> >
> > now I would like to use one entry of this map as a model for TextField:
> >
> > new RequiredTextField<>("componentId", new
> > PropertyModel<>(modelObject.getConfig(), "VALUE1")))
> >
> > but when saved to DB Hibernate says the key is String and Enum is
> expected:
> > java.lang.ClassCastException: java.lang.String cannot be cast to
> > java.lang.Enum
> >
> > Using ChainingModel or
> > Model.of(modelObject.getConfig().get(MyEnum.VALUE1))) causes the value
> not
> > to be bind at all.
> >
> > I know I can use "side" property and fill this map manually in onSubmit
> > just before saving to DB but would like to avoid that.
> >
> > Thanks
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to