Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Struts 2 forms and collections

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have recently made the move from Struts 1 to Struts 2 and am really glad I made the move. With one exception. For some reason I really have a tough problem coding my JSP code to properly access data from my action module. It is improving but I find using collections a total mistery. I have a page I am trying to get working where a Collection is the only practical answer. There are a variable number of entries that should appear on a form, give the user the opportunity to change a column of numbers then submit the data for update to an sql table.

I have tried coding this several different ways using HashMaps, ArrayLists and arrays and so far have not got it working properly. I can get the current data to display on the form but no data ever returns back to the action module.

I have set up a small bean that holds each instance of the data:



In the action class I build an ArrayList of these beans with data from an SQL table. Also I have appropriate getter and setter in the action class for the ArrayList object.



In my jsp/Struts 2 code I build a form and populate it using an iterator.




When I bring up the form and look at the html source it contains what appears to me to be accurate coding. Here is a small example:




When I make changes and then submit the form the ArrayList has the correct number of entries. But they are all null. In another combination using HashMap I was able to get the date back properly but the headCount field was null. In another case the headCount field had an OGNL error message in it.

I have tried using a simple HashMap with the date as the key and a Double for the count (nulls in count). I have tried TreeMap using date for sequence and then CraftLaborPeriodDetail as the value (nulls for value). So I am missing something very basic when it comes to getting data BACK INTO the collection following a submit. ALSO, I tried changing the double to a String just to see what would happen and nothing changed. It still came back as a null.

Please help. I am getting desparate to get this module completed so I can make progress on my development.
 
Glenn Puckett
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow.. Thanks for the overwhelming response!!!
    Bookmark Topic Watch Topic
  • New Topic