• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Use ArrayList in ActionForm

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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:



[ June 08, 2006: Message edited by: JW Li ]
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This link should give you some ideas on what to do.
 
JW Li
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Merrill,

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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic