Hi Rick,
Thanks for helping!
I think I see what you are saying, but in my case I am collecting information from the user that I have never seen before. Don't know what they will enter into the field. I mean, I could put default information in there like "Enter lot number here", but I have no idea what the lot number will be until they type it in...if you get what I mean....
I am trying to let the user enter information about a lot of slides that they are using, but they may be using several lots of slides and the number of lots will change every time they use the application...thus I want present a page that has a field for entering information for one lot...then I have a "add another lot" button that they can click that will allow them to enter the information for a second lot, but they should still be able to see the information they entered for the first lot, thus they will see two textfields...actually there are corresponding textareas for each textfield as well, but assuming I can get the textfield to work, I can follow suit with the textarea. In fact, they should be able to keep clicking "add new lot" without filling anything out until the end if they like...
Lynn
From: Rick Reumann <[EMAIL PROTECTED]> Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> To: Struts Users Mailing List <[EMAIL PROTECTED]> Subject: Re: setting a collection in my form bean using iterate or forEach Date: Sun, 22 Aug 2004 23:55:57 -0400
Lynn Stevens wrote:No I am not getting any errors. I would paste the code now, but its at work and I am at home...I will paste it in the moring. If I am inside an iterate tag, it does not iterate at all because the String[] is empty.
But why is empty? In other words if these are text fields you expect to filled out then it shouldn't be empty when you get to the form. That is if you plan to loop/iterate over a form field then it needs to be prepopulated with what you want.
If I change to a for:Each jstl tag and tell it to loop say 3 times, it prefills all of my html:textfields to show the pointer location of the String[].
Well in the above when you say it "prefills" all of you textfields, you don't mean it's filling them with appropriate text field values.
Assuming you want to use a String[], what I think you want to do is...
(Lets assume you are doing an update of maybe a String[] array of automobile names)...
in a setUp dispatch method call backend and then populate your form String[] automobileNames with the names. )One important thing to note though is that you will have to have intialized your array in the form to at least not be null or else you'll probably end up with some NullPointer Exceptions)
Now forward to form....
<c:forEach items="${yourForm.automobileNames}" var="name"> <html:text property="automobileNames" value="${var}"/> </c:forEach>
Something like the above should work.. then when the form submits you'll have the String[] automobileNames populated with all the names (which in the above could have been edited by the user).
-- Rick
--------------------------------------------------------------------- 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]