Ok, I changed the name and am still having the same issue... the iterator does nothing. I think your second comment is the cause. I guess I was just confused about when to use the form-property tag, I don't use DynaActionForm.
My flow is as follows:
1. Action /submit.do is a forward to submit.jsp without an action type. 2. Clicking submit does onsubmit validation and calls a different action: /submitAction.do to do server side validation and processing - and this does have an action type.
I have two actions because I don't want validation (and the associated errors) with showing the form the first time. Perhaps there is a better approach to this?
So without using a DynaActionForm, I guess I need to have a different action associated with 1 that pre-populates the form so the rows show up.... off to try it now.
Originally posted by Brian Harper: I guess I was just confused about when to use the form-property tag, I don't use DynaActionForm.
This is what struts-config_1_2.dtd says about "form-property" element:
The "form-property" element describes a JavaBean property that can be used to configure an instance of a DynaActionForm or a subclass thereof. This element is only utilized when the "type" attribute of the enclosing form-bean" element is [org.apache.struts.action.DynaActionForm] or a subclass of DynaActionForm. If a custom DynaActionForm subclass is used, then the "dynamic" attribute of the enclosing <form-bean> element must be set to "true". Since Struts 1.1.
So If you are not using DynaActionForm, then remove that element.
1. Action /submit.do is a forward to submit.jsp without an action type.
Now, While forwarding to JSP page on which you are iterating , then simply add the name of "bean" in action mapping tag.. like
<action .. name="submitForm"/>
A question : Any special reason to use array of size 5(You can show 5 empty rows by iterating 5 times), If no, then have look at this FAQ, It might help !!
Joined: Dec 31, 2008
I've got it working now, I stopped using the array example and followed the FAQ exactly. I had looked at it before, but I was still working off of a different example that used an array.
And I guess you're right, it makes more sense to just iterate in the JSP if the List is empty than to add empty elements to the list.
I'd also like to expand the list dynamically without submitting.... (e.g. add another row by clicking a button). this seems to help with that, I just need to figure out how to get the last index so I can increment it. Any tips on that?