Well, I have tried the following:

With the following velocity code:

#set( $i = 0 )
#foreach ($param in $dataApplication.paramsList )
  $param.nameparam : $param.descparam
  <input type="hidden" name="nameParam[$i]" value="$param.nameparam">
  <input type="text" name="valueParam[$i]">
  #set( $i = $i +1 )
#end
<input type="submit" value="$text.get("common.run")">

I obtain the following HTML code:

<form name="param" action="/PortalCCG/runJob.do">
  <input type="hidden" name="nameParam[0]" value="i">
  <input type="text" name="valueParam[0]" value="">
  <input type="hidden" name="nameParam[1]" value="toto">
  <input type="text" name="valueParam[1]" value="">
  <input type="submit" value="Run">
</form

Struts-config.xml is defined as is:

<form-bean name="runJobForm"
     type="org.apache.struts.action.DynaActionForm">
     <form-property
            name="nameParam"
            type="java.util.ArrayList"/>
     <form-property
            name="valueParam"
            type="java.util.ArrayList"/>
</form-bean>

And I try to retreive my parameters in my Action Class as is:

DynaActionForm resultJobForm = (DynaActionForm)form;
ArrayList nameParam = (ArrayList)resultJobForm.get("nameParam");
ArrayList valueParam = (ArrayList)resultJobForm.get("valueParam");

But executing, I have the following error:

javax.servlet.ServletException: BeanUtils.populate
        org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1254)

root cause

java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
        java.util.ArrayList.RangeCheck(ArrayList.java:546)
        java.util.ArrayList.set(ArrayList.java:337)
        org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:460)

Some ideas??

Pierre

> Great! I'll test it and let you learn!
>
> Thanks a lot,
>
> Pierre
>
>> --- Pierre-Alain Branger <[EMAIL PROTECTED]> wrote:
>>> Yes I have seen that it is possible to use an
>>> ArrayList in DynaActionForm.
>>> [...]
>>
>> <input type="text" name="value[index]">
>>
>> You may need to just add an index from your iteration
>> to the input tag.
>>
>> http://struts.apache.org/1.2.9/faqs/indexedprops.html
>>
>> might provide more insight than I have time for right
>> now :) But basically if you're building the input tags
>> by hand IIRC you can just add the array notation and
>> as long as it's defined as an array in your ActionForm
>> (or DynaActionForm) you may be okay (I did something
>> similar, also with Velocity).
>>
>> Dave
>>
>>
>>
>>
>> ____________________________________________________________________________________
>> Do you Yahoo!?
>> Everyone is raving about the all-new Yahoo! Mail beta.
>> http://new.mail.yahoo.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
>
> Pierre-Alain Branger
> Program of Computational Genomics
> Campus Morelos
> Tel. +52 777 13 100 24
> [EMAIL PROTECTED]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


Pierre-Alain Branger
Program of Computational Genomics
Campus Morelos
Tel. +52 777 13 100 24
[EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to