Hello Li,

I'm using struts 2. I'm not getting an IndexOutOfBoundsException,
instead the list is populated with null values.

Dave

On Wed, Oct 13, 2010 at 7:20 PM, Li Ying <liying.cn.2...@gmail.com> wrote:
> 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:
>
> action.getCellCosts().get(0).get(4).setQuota(value);
>
> 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 <dsevan...@gmail.com>:
>> 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: user-unsubscr...@struts.apache.org
>> For additional commands, e-mail: user-h...@struts.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to