struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Li Ying <>
Subject Re: ognl and multdimensional lists
Date Thu, 14 Oct 2010 02:20:48 GMT
Hi Dave:

What version of Struts are you using?

A long time ago, i met the similar problem in Struts1.

I thought the parameter named "cellCosts[0][4].quota"

should be translated into java code likes:


And the method [get] throws a IndexOutOfBoundsException because there
were not element in the list yet.

My solution was:
1,Create a new List class named [AutoList], which expend from class [ArrayList].
2,Override the method [get] of [AutoList], create instances of element
and insert them into the list before the old [get] method is executed,
so we the list can be populated automatically and the method [get]
will not  throw IndexOutOfBoundsException.
3,In Action/Form class, use the new AutoList instead of ArrayList.

In Struts2, I am not sure how OGNL process this case.

2010/10/14 Dave Evans <>:
> Hello,
> I've got an action  with this property:
> private List<List<CellCost>> cellCosts;
> public void setCellCosts(List<List<CellCost>> l) {
>   this.cellCosts = l;
> }
> public List<List<CellCost>> getCellCosts() {
>   return this.cellCosts;
> }
> The outer list is a list of locations, each of which has a list of
> cellCosts. These are dynamically sized.
> The jsp has this in two nested jstl forEach loops:
> <input name="cellCosts[${locationStatus.index}][${cellCostStatus.index}].quota"
> type="text" value="${cellCost.quota}" />
> which renders to (as an example):
> <input name="cellCosts[0][4].quota" type="text" value="10" />
> Ognl doesn't seem to be populating the cellCosts list.
> Any suggestions?
> Thanks,
> Dave
> Dave
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message