[ 
https://issues.apache.org/struts/browse/WW-2513?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=44426#action_44426
 ] 

Musachy Barroso commented on WW-2513:
-------------------------------------

Forgot to say, this was fixed on xwork r1852

> EnumMap's not supported in type conversion + InstantiationException
> -------------------------------------------------------------------
>
>                 Key: WW-2513
>                 URL: https://issues.apache.org/struts/browse/WW-2513
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Tags
>    Affects Versions: 2.0.11
>         Environment: Windows 2000 SP4
> WebLogic Server 9.2 M1
> JVM 5.0 (build 1.5.0_06-b05) - bundled with WLS installation
>            Reporter: Maxx
>             Fix For: 2.1.3
>
>         Attachments: struts.xml, test.jsp, TestAction-conversion.properties, 
> TestAction.java, TestEnum.java
>
>
> Unlike regular classes implementing interface java.util.Map, EnumMap are not 
> well supported through the (automatic?) "Type Conversion" as described here: 
> http://struts.apache.org/2.x/docs/type-conversion.html
> 1/ the values can't be retrieved through the use of some map-like OGNL 
> expressions like %{myEnumMap['myEnumValue']}
> Neither by just removing the single quotes i.e. %{myEnumMap[myEnumValue]} or 
> by using the @...@ notation e.g. [EMAIL PROTECTED]@MyEnum.myEnumValue]} it 
> still doesn't work.
> In the example below, the corresponding <s:textfield /> are not populated, 
> while the ones for the Map are.
> 2/ when setting values back to the object, an InstantiationException occurs.
> Effectively, an EnumMap has NO no-arg constructor because initializing an 
> Enum needs to set a parameter: the enum type.
> Note: IMHO looking for a declared no-arg constructor is wrong as Java 
> automatically declares a public no-arg constructor, but here it's not exactly 
> the problem (I'll come back later to this with another issue).
> See attached files for a full running example:
> - TestAction.java:
>  * 1 Map & 1 EnumMap are initialized with 2 entries (key+value) both
>  * the execute() method does the initialization, while the executeLog() does 
> the logging.
> - TestAction-conversion.properties: the appropriate type conversion 
> properties file
> - TestEnum.java: the Enum used as key universe for the EnumMap
> - test.jsp: contains too iterators over the Map & the EnumMap
> - struts.xml (but it's succinct)
> Note: the conversion settings for the testMap seem not to be mandatory as 
> setting back the values into the action without them works fine.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to