Hi all, I've been researching how to handle arrays in DynaActionForms. In other words, situations where you need an array or list to represent rows of data on the screen and most especially when you don't know how any entries will be on the page. I looked around the web and found all sorts of hacks to get around the problem that
struts does not initialise the arrays. Some people advocated inserting extra actions, loading stuff into session and all sorts of things. All of which sounded problematic, labour intensive and not really addressing the problem (No insults intended).
So I had a look at the struts code and came up with the following extension to the DynaActionForm. So far I've tested it using definitions of both a
String array and LinkedList in my struts-config.xml and they have worked perfectly without requiring any extra actions or code to set them up. This version of the form basically extends arrays and lists on demand as the framework loads the data. Missing entries such as indexes 4 and 5 in my sample
jsp are left as nulls.
Any comments welcome. I don't think I've doubled on anyones work, but let me know as I searched for solutions like this but didn't find any.
Sample struts-config.xml:
And a sample Jsp page:
And finally a sample action:
[ August 29, 2005: Message edited by: Derek Clarkson ]