I believe you'll have to write a TypeCoercer from String to EnumType and
back and contribute that to the TypeCoercer service. See
http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/services/TapestryModule.html
for examples how to do this.

But if you can live with your values not being literal strings, you could
just follow the example here:
http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry5/corelib/components/Radio.html

HTH,

Uli

Am Mi, 8.10.2008, 15:10, schrieb Alexey Hanin:
> Hello,
>
> I'm trying to use RadioGroup with Enum values and getting
> ClassCastException: java.lang.String cannot be cast to java.lang.Enum.
>
> My page is as follows:
>
> public class Page {
>
>     private EnumValueEncoder<EnumType> enumTypeEncoder = new
> EnumValueEncoder<EnumType>(EnumType.class);
>     private EnumType enumType;
>
>     public EnumType getEnumType() {
>         return enumType;
>     }
>
>     public void setEnumType(EnumType enumType) {
>         this.enumType = enumType;
>     }
>
>     public EnumValueEncoder<EnumType> getEnumTypeEncoder() {
>         return enumTypeEncoder;
>     }
> }
>
> public enum EnumType {
>     A, B
> }
>
> <t:radiogroup t:id="enumType" t:encoder="enumTypeEncoder">
>     <input t:type="radio" t:value="literal:A"/>
>     <input t:type="radio" t:value="literal:B"/>
> </t:radiogroup>
>
> I supposed literal representation must be evaluated to corresponding
> enum values and wise-versa, but I got a ClassCastException.
>
> I found this way logical and I really don't want to use getters for
> every element of enum. Is there any ways to achieve this?
>
> Tapestry version is 5.0.15
>
> Regards,
> Alexey.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to