I used ArrayList in my ActionForm, but when I tried to access the ArrayList in JSP, I always get IndexOutOfBoundsException from ArrayList (which has size 0). If I change the ArrayList to type array, then everything works fine (I need to initialize the array in ActionForm to some fixed bigger size first). Under certain situation, I really want to use ArrayList to capture user input data, since I don't know how many the user is going to enter. Could someone help me on this problem? Thanks a lot in advance. What follows is my code:
Thanks very much for your information! I tried most of the suggestions on that page, but still have problem I think I might have done something wrong, which is too subtle to be found... Sometimes the error is cannot find setXXX method when it's actually clearly defined in the ActionForm, and sometimes it's about getXXX not defined, (and I got confused by plural/single methods, like getter methods for items data member, we should have getItems() of course, and getItems(int index), or getItem(int index)..., when I have getItems() and getItems(int index), struts complains it cannot find getItems... I also tried LazyList, but got argument mismatch on the setter method after post the form(i.e. setItems())... Anyway, I feel highly frustrated by the way struts handle ActionForm. It has way too many black boxes (dependenency on common.beanutils implementation, from where I got most of the exception, and don't know what to do with them...) I really don't think it's worthy of a developer's time to try to resovle a simple post problem, which if doing old fashioned way, is much simplier and clearer... I feel I should start to think seriously about moving to other framework at all, though not clear what's better out there now. Anyway, for my original problem, I could just use Array and finish the work. I gave up using ArrayList in the ActionForm. Thanks again for your help. At least, now I know it's part of their bugs.
If you were a tree, what sort of tree would you be? This tiny ad is a poop beast.