-1

Im in a critical problem. Basically whats happening is that first I set an arraylist object inside a bean class. This bean now contains all the values of that list after I checked this while debugging.

These bean values are now passed on to the JSP where they are used for some UI presentation logic. Now I submit this JSP and a new action method is called.

Now what happens is that when I retrieve that list in the new action method..I get that list but all the values inside that list have changed to null!

Could someone please explain to me what the problem is?

I cant share the code as its confidential. Someone please give me an idea about what I should do!

Siddharth Mehta
  • 445
  • 3
  • 7
  • 17
  • Are you using struts or just plain servlet/jsp? – Darshan Mehta Dec 16 '15 at 15:15
  • struts 2 and jsp only – Siddharth Mehta Dec 16 '15 at 15:16
  • 4
    Everyone's code is confidential. *Your* job is to strip from it only the **relevant** portions of the code (action snippet, jsp snippet, struts.xml snippet, etc...) and then alter the variable's names and / or remove the sensitive data. This way you can ask the question properly without worrying of being leaking informations about your software. – Andrea Ligios Dec 16 '15 at 15:36
  • I think this will solve your problem. http://stackoverflow.com/questions/27243603/what-does-status-in-siterator-do – Unknown Dec 18 '15 at 11:34

2 Answers2

0

You need to play around with 'name' element for s:property tag for struts 2. E.g. while irerating the list, you need to create elements with 'name' attribute like name="addresses[0].houseNo" and so on. Once this is set, you will get the full list with all the elements set in the action class.

This example explains it thoroughly.

Darshan Mehta
  • 30,102
  • 11
  • 68
  • 102
0

Sorry for the late reply, but the answer is quite simple. Basically, I specified the bean in request scope via Spring configuration earlier which actually prevented the values from persisting in the next request. To fix the issue, I relayed the values using Struts 2 hidden fields which solved the issue completely.

Siddharth Mehta
  • 445
  • 3
  • 7
  • 17