You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sami Dalouche <sk...@free.fr> on 2007/02/11 21:18:40 UTC

Binding Java 5 Enums..

Hi,

I've been trying to bind Java 5 enums, but I get some weird problem....

xwork-conversion.properties 
java.lang.Enum = funala.web.action.typeconverters.TestTypeConverter

TestTypeConverter extends EnumTypeConverter and just adds some logs, to
make sure the converter is actually used. (I get the same problem by
using the EnumTypeConverter directly)

So, the weird thing is that binding from the Enum to String works
perfectly, but the opposite doesn't work..
(the Enum is SexTraitType, and contains MALE, FEMALE)

[INFO] [2007-02-11 20:58:39,959]
[funala.web.action.typeconverters.TestTypeConve
rter] (btpool0-3,) : convertValue: [Ljava.lang.String;@16bfded:class
funala.doma
in.entity.profile.traitTypes.SexTraitType
[INFO] [2007-02-11 20:58:39,959]
[funala.web.action.typeconverters.TestTypeConve
rter] (btpool0-3,) : convertFromString: FEMALE:class
funala.domain.entity.profil
e.traitTypes.SexTraitType
[ERROR] [2007-02-11 20:58:39,964]
[com.opensymphony.xwork2.interceptor.Parameter
sInterceptor] (btpool0-3,) : ParametersInterceptor - [setParameters]:
Unexpected
 Exception catched: Error setting expression 'sexTrait' with value
'[Ljava.lang.
String;@16bfded'


(and I do have my get/set sexTrait() on the action.
{
..
}

Does anyone know what could cause the problem ? 

Thanks for your help,
Sami Dalouche


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Binding Java 5 Enums..

Posted by Daniel Amadei <da...@gmail.com>.
Hi Sami,

There is an example in the showcase webapp which shows how to convert
to/from enums. Give a look, that it might help you.

[]s
Daniel

2007/2/11, Sami Dalouche <sk...@free.fr>:
> Hi,
>
> I've been trying to bind Java 5 enums, but I get some weird problem....
>
> xwork-conversion.properties
> java.lang.Enum = funala.web.action.typeconverters.TestTypeConverter
>
> TestTypeConverter extends EnumTypeConverter and just adds some logs, to
> make sure the converter is actually used. (I get the same problem by
> using the EnumTypeConverter directly)
>
> So, the weird thing is that binding from the Enum to String works
> perfectly, but the opposite doesn't work..
> (the Enum is SexTraitType, and contains MALE, FEMALE)
>
> [INFO] [2007-02-11 20:58:39,959]
> [funala.web.action.typeconverters.TestTypeConve
> rter] (btpool0-3,) : convertValue: [Ljava.lang.String;@16bfded:class
> funala.doma
> in.entity.profile.traitTypes.SexTraitType
> [INFO] [2007-02-11 20:58:39,959]
> [funala.web.action.typeconverters.TestTypeConve
> rter] (btpool0-3,) : convertFromString: FEMALE:class
> funala.domain.entity.profil
> e.traitTypes.SexTraitType
> [ERROR] [2007-02-11 20:58:39,964]
> [com.opensymphony.xwork2.interceptor.Parameter
> sInterceptor] (btpool0-3,) : ParametersInterceptor - [setParameters]:
> Unexpected
>  Exception catched: Error setting expression 'sexTrait' with value
> '[Ljava.lang.
> String;@16bfded'
>
>
> (and I do have my get/set sexTrait() on the action.
> {
> ..
> }
>
> Does anyone know what could cause the problem ?
>
> Thanks for your help,
> Sami Dalouche
>
>
> ---------------------------------------------------------------------
> 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