• 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

Using ArrayLists with struts

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I'm quite new to Struts and JSP's and I'm trying to iterate over an ArrayList to set some properties but I really can't figure out what is going wrong. I've looked up and tried several ways to do it and here's briefly what I've done in the jsp page :



Which gives me the error message :



strPostNeeds is the ArrayList I want to fill and has the same length as the array postNames. Maybe I should use the set method instead of get but I don't know I could do that. I've tried to make that using regular arrays instead but I need to have a dynamic one because I perform tests on all its values afterwards.

Any suggestion would be welcome.

Thanks in advance,

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

This line of your makes no sense. It is actually evaluated to:



As you can very well see, the servlet then tries to invoke that method on your beanObj and throws an exception.
Also, if you're using JSTL, then there's really no need to use "logic" tags.
If you can clearly state what it is you need to achieve conceptually, [copy contents of one arraylist into another?], then it'll be much easier to assist you.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your code indicates a lack of understanding of how indexed properties work. It's not enough just to specify indexed="true". You must create an indexed getter in your form bean and name the properties appropriately.

My suggestion is to review this link from this forum's FAQ. Particularly look at the example code given. If you still have questions, let us know.
 
Roscoe Padsmith
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for these useful links, it helps a lot. I've managed to fix my problem but then some other ones (things with hibernate and all) appear as usual. Anyway thank you again.

-- Alain
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic