When using indexed properties you must provide an indexed getter and setter, which you have not. You must also initialize the array to the number of elements you expect. If you don't know how many elements, use a java.util.List instead of an array. Also, indexed="true" works only for an array or list of JavaBeans, not for a simple array. For a simple array, you have to build the the indexed property name yourself. Example:
Thanks Merrill, It did work. But was a little curious about the usage of List. Can you give me some pointer how to use it. The number of components is dynamic and is not restricted.
Joined: Feb 15, 2005
I'm glad it worked.
Before we go any further, though, one of my duties as forum moderator is to see that the guidelines are followed, and I noticed the name you are currently displaying does not meet the guidelines of the JavaRanch Naming Policy. In particular, the name you display must be a first and last name, and must not be obviously fictitious. Please change the Publicly Displayed Name in your user profile so that it meets the guidelines.
This may seem trivial to you, but it's an important part of the culture at JavaRanch, and we do appreciate your compliance with it.
Regarding your question about using a List, you would just change the underlying representation of customDocs variable from an array to a List. You would then modify the getter and setter accordingly. You would also have to give your accessors "lazy initialization" behavior. For more information and an example of this, see question 6 of this forum's FAQ.
Joined: Nov 26, 2007
Well Merrill, Thanks.. Well Just added a caption as usual. Didn't know that it will create problems any way changed it Thanks for your help
According to above discussion about multiple file upload in struts 1.x, I am also facing the same problem, i am trying to upload dynamically multiple files through action class, but i have referred above discussion and tried to incorporate in my code but when i login and click on my jsp page error is coming as "Cannot create iterator for this collection"
Pradeep venkatesh wrote:i have referred above discussion and tried to incorporate in my code
I don't think you did because if you look at the method signatures Merrill suggests, you will see that yours do not match.
I question the utility of this approach. Why are you initializing the list of files on the JSP? Wouldn't that require you to know what files exist on the client?
No , I do not need to know what files are on the client side, But i am suppose to allow users only image files to upload, so i thought of using that in my code, can you please give me any suggestions for how to make this thing work?I mean I want to upload multiple files in struts 1.x when i submit the form all files should save in folder in local drive.
Pradeep venkatesh wrote:i am suppose to allow users only image files to upload, so i thought of using that in my code, .
I have no idea how that approach would work. The file tag has an "accept" parameter where one can specify a list of MIME types that are allowed. I assume you could also use server-side validation to check the submitted file names, but that would not be idea as the data would have to be transferred before the check can be done.
Joined: Mar 03, 2013
Hi Joe Ess,
Thank you so much for the suggestions, I will check the file types using server side validations.
I am very new to struts, and i am trying to upload multiple files, we have dynamic add button whenever i click on that button a new row will be added to upload file but with the same property, every time i want to change the property when i add new row , so i was going through the internet i got this solution with the below code, but i am not getting how to work with the below code , can anyone help me with this? any help will be appreciated.
Can any one please tell me how the below code works?
how this code works? and what is "upLoadList" ? from where the values are getting generate for this list?
is that every time i add one more row the property can be changed dynamically? with the index ?. please help.