• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

nested iterate with ArrayList

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not familiar with Struts, please forgive me if I'm asking stupid question.

My struts-config:


My jsp:


the jsp can successfully generate the corresponding page with correct data in the html:


However, when I try to submit this page to the action class, before reaching the action class, it generates:


Why is that? How can I solve it?
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'll either have to change some code (most DynaUsers prefer not to) or put the form in session scope.

What is happening:
1) I assume their is an Action to populate the ActionForm with orderDetails before going to the jsp because you show that it prepopulates correctly.
2) When you submit the jsp, orderDetails[0].itemId is calling:
getOrderDetails("0").setItemId() but fails because the orderDetails' values are not in the ActionForm (a new ActionForm is created for the submission because it is declared as request scope and, well, this is a different request from the user).
3) At this point it looks for the index of 0 in the orderDetails ArrayList but finds that the list is empty (size=0) and throws and IndexException

If you're not afraid of getting your hands dirty you can come up with a way to put the ArrayList back into the new ActionForm. The reset() method might be a good place to do this.
 
MK Lee
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hahaa...
i used the simplest trick: modify the form scope to session
and it works fine
Thx a lot
^3^
 
Life just hasn't been the same since the volcano erupted and now the air is full of tiny ads.
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic