<form-property name="myproperty" type="java.util.ArrayList" /> ...
<action name="myForm" scope="session" .. ..
ArrayList myList = new ArrayList()
theForm.set("myproperty",myList);
.. <logic:iterate id="foo" name="myForm" property="myproperty">
..
Cheers Mark
On Tuesday, October 21, 2003, at 12:33 PM, Frederic Dernbach wrote:
OK, I faced the same problems you a few weeks ago (I was a total newbee with indexed properties and I spent 10 full days on the problem - I'm still hot on this one !).
I haven't read the initial post and I hope my input will be useful to you.
Regarding the form : 1/ I create an empty array list in the constructor : ArrayList awards = new ArrayList();
2/ I do the same in the reset() method. Create the an empty ArrayList. Do not set the list to null items like you proposed, otherwise you will have problems with the BeanUtils.populate() method when forwarding a struts request.Reset the list elements to null only for boolean elements.
3/ Have the following the setter and getter methods in your form (and perform laying list initialization for the 'Award' form property) : public ArrayList getAwards() { return awards } public void setAwards (ArrayList awards) { this.awards = awards; }
public AwardMasView getAward(int index) { while( index >= awards.size() ){ awards.add(new AwardMasView()); } return (AwardLasView) awards.get(index); } public void setAward(int index, AwardMasView object) { while ( index >= awards.size() ){ awards.add(new AwardMasView()); } awards.set(index, object); }
In a JSp you can now use tboth the 'Awards' and 'Award' form property ('Award' being the INDEXED property) :
<logic:iterate name="youtformname" property="awards" id="award" type="path.to.your.form.yourformname"> <html:hidden name="award" property="youtpropertyname" indexed="true"/> </logic:iterate>
Note that the 'id' attribute of the <login:iterate> has to be equal to the name of your indexed property ('Award').
And do not forget to include every indexed property in your form (liek the example above) if you are using <bean:write> tag to display your indexed property, otherwise you will have problems with BeanUtils.populate() methods.
Cheers,
Fred
Le mar 21/10/2003 à 09:29, hsc a écrit :i have same question as you , do you have get right answer? my resolve is like this :
form bean - private ArrayList awards = new ArrayList (5); public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { awards .add(0,new AwardMasView ()); awards .add(1,new AwardMasView ()); awards .add(2,new AwardMasView ()); awards .add(3,new AwardMasView ()); awards .add(4,new AwardMasView ()); }
the program can right work, but ArrayList's length is fixed .
if you have get right answer ,would you maind share whit me.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]