This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.