You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Damian <da...@webmedia.ro> on 2009/10/13 13:48:01 UTC
Conversion problem for bi-dimensional Lists and Arrays
Hi all,
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:
List<List<Currency>> currencyMatrix
In the view:
currencyMatrix[0][1].value
(currencyMatrix[0])[1].value
currencyMatrix.get(0).get(1)
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
List<RowDTO<Currency>> currencyMatrix
where RowDTO<T> represents a row, having a field List<T> rowElements
In the view:
currencyMatrix[0].rowElements[1].value
Same as above, currencyMatrix is filled with null elements
3)In the action:
List<currencyRowDTO> currencyMatrix
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
Thanks you in advance
--
Damian
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org