Struts2 - Conversion problem for bi-dimensional Lists and Arrays
Ioan Damian Sirbu
Joined: Dec 22, 2008
Good morning, this is a detailed follow up to a similar post I placed in the wrong section (sorry about that..).
I want to send a bidimensional List and/or a bidimensional array from my application's view to the action.
For example, I have a generixMatrix object in the action (with getters and setters of course). The genericMatrix should be able to hold any kind of object.
I want to set a 'Currency' object's 'value' field from the view, using an <input name="OGNL expression" value="theValue">
My problem is that i cannot address the Currency object properly with OGNL, or Struts does a bad type conversion.
I tried to represent a currencyMatrix that holds Currency objects
1) In the action:
In the view:
None of these are working. I debugged and noticed that currencyMatrix gets initialized, but instead of RowDTO<Currency> elements, all its elements are null.
2) In the action
where RowDTO<T> represents a row, having a field List<T> rowElements
In the view:
Same as above, currencyMatrix is filled with null elements
3)In the action:
and RowDTO has a typed list List<Currency> currencyRowElements.
It works, but it does not help me. This forces me to create a new row object each time, like personRowDTO, anotherRowDTO etc.
Struts2 documentation specifies that "the Struts 2 type conversion mechanism can use generics-based typing to learn the correct target type for the conversions", but I think it defects when having nested generic types.
I also tried using a bidimensional array like Currency but again I cannot find a way to reffer to it with OGNL.
I am open to any suggestions. To make a long story short, all I need is a sollution for a matrix-like object that can hold any type of object