Struts2 Converting Enum Array fills array with single null value

Posted by Kyle Partridge on Stack Overflow See other posts from Stack Overflow or by Kyle Partridge
Published on 2010-06-15T17:31:36Z Indexed on 2010/06/15 20:22 UTC
Read the original article Hit count: 248

Filed under:
|
|

For a simple action class with these member variables:

...
private TestConverterEnum test;
private TestConverterEnum[] tests;
private List<TestConverterEnum> tList;
...

And a simple enum:

public enum TestConverterEnum {
    A,
    B,
    C;
}

Using the default struts2 enum conversion, when I send the request like so:

TestConterter.action?test=&tests=&tList=&b=asdf

For test I get a null value, which is expected. For the Array and List, however, I get and Array (or list) with one null element. Is this what is expected? Is there a way to prevent this.

We recently upgraded our struts2 version, and we had our own converters, which also don't work in this case, so I was hoping to use the default conversion method. We already have code that is validating these arrays for null and length, and I don't want to have to add another condition to these branches. Is there a way to prevent this bevavior?

© Stack Overflow or respective owner

Related posts about java

Related posts about struts2