You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Daniel Amadei <da...@gmail.com> on 2007/02/08 02:24:52 UTC
binding select value to a Java 5 enum
Hi All,
I`m trying to bind the value of a select to an enum but I`m getting
the following error:
Invalid field value for field
Does anybody knows how can I set the value to be the enum type?
Thanks,
Daniel
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: binding select value to a Java 5 enum
Posted by Laurie Harper <la...@holoweb.net>.
That's a known limitation of the s:select tag, which only works with
string-valued properties. The most straight-forward workaround is to set
value, as in:
<s:select name="property1" value="property1.toString()"/>
L.
Daniel Amadei wrote:
> Hi Dave/All,
>
> It worked fine even tough I had to put the fully qualified name of the
> field.
>
> What is not working is when I post back to my JSP, the select field is
> not automatically selected, as a workaround, I had to specify in the
> value of the field a method in my action which tells what item is
> selected. This way, it works fine.
>
> Does anybody have an idea why?
>
> Thanks,
> Daniel
>
> 2007/2/7, Dave Newton <ne...@yahoo.com>:
>> --- Daniel Amadei wrote:
>> > person.gender=mypackage.EnumConverter
>> > Element_person.gender=mypackage.Gender
>>
>> Does it work if you remove the "person." part? I'm
>> still not entirely clear why one of my current apps
>> does conversion correctly, but my -conversion file
>> only has the last part of the object graph in it.
>>
>> d.
>>
>>
>>
>>
>> ____________________________________________________________________________________
>>
>> Don't pick lemons.
>> See all the new 2007 cars at Yahoo! Autos.
>> http://autos.yahoo.com/new_cars.html
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: binding select value to a Java 5 enum
Posted by Daniel Amadei <da...@gmail.com>.
Hi Dave/All,
It worked fine even tough I had to put the fully qualified name of the field.
What is not working is when I post back to my JSP, the select field is
not automatically selected, as a workaround, I had to specify in the
value of the field a method in my action which tells what item is
selected. This way, it works fine.
Does anybody have an idea why?
Thanks,
Daniel
2007/2/7, Dave Newton <ne...@yahoo.com>:
> --- Daniel Amadei wrote:
> > person.gender=mypackage.EnumConverter
> > Element_person.gender=mypackage.Gender
>
> Does it work if you remove the "person." part? I'm
> still not entirely clear why one of my current apps
> does conversion correctly, but my -conversion file
> only has the last part of the object graph in it.
>
> d.
>
>
>
>
> ____________________________________________________________________________________
> Don't pick lemons.
> See all the new 2007 cars at Yahoo! Autos.
> http://autos.yahoo.com/new_cars.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: binding select value to a Java 5 enum
Posted by Dave Newton <ne...@yahoo.com>.
--- Daniel Amadei wrote:
> person.gender=mypackage.EnumConverter
> Element_person.gender=mypackage.Gender
Does it work if you remove the "person." part? I'm
still not entirely clear why one of my current apps
does conversion correctly, but my -conversion file
only has the last part of the object graph in it.
d.
____________________________________________________________________________________
Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.
http://autos.yahoo.com/new_cars.html
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: binding select value to a Java 5 enum
Posted by Daniel Amadei <da...@gmail.com>.
Hi All,
Per my message above I was able to set value for an Enum which is a
property of my action using a converter as in the showcase example,
but I was not able to set the enum to a nested, when the enum never
gets called.
My structure is similar to:
person.gender (where gender is an enum)
My conversion file is like this:
person.gender=mypackage.EnumConverter
Element_person.gender=mypackage.Gender
This way, the property person.gender is always null. Can somebody help me?
Thanks,
Daniel
2007/2/7, Daniel Amadei <da...@gmail.com>:
> Hi All,
>
> I`m trying to bind the value of a select to an enum but I`m getting
> the following error:
>
> Invalid field value for field
>
> Does anybody knows how can I set the value to be the enum type?
>
> Thanks,
> Daniel
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org