Cutting right to the chase...

I'm curious on how others handle the age-old struts problem of: "How do you
handle nested objects in an ActionForm that have non String properties that
might be editable by a user on a JSP?"

To provide a watered down example...

Imagine you go to the DB to get a List of Company objects. Each company
object in the List has nested in it a List of Division objects. Each
Division has a "date" field in it (say a startDate). You then need to
display a form that displays the companies and divisions and could allow the
user to edit the date (in a free-form text field) and submit the form.

Things work fine if you didn't have to worry about form validation - in
which case, you could just have one property in your ActionForm:  List
companies; //set/get  and you are done (using the List of Company value
objects). You'd display the data on the form and submit and things are nice.

However, nested sort of deep is that "date" field. If the user enters in the
date wrong we want to return to the page and display what they entered so
they can fix it. This can't be done if you just want to use the nested value
object(POJO) approach.

This above scenario is Strut's biggest weakness. (It's compounded with
BeanUtils crazy notion of also not keeping wrapper clases like Integer truly
"null" when a String is null - instead it decides to make the Integer 0).

Besides wondering how others deal with this annoying problem (other than
moving to another framework like JSF), I was wondering if maybe DyanForms
could be a solution? Can you nest them ? If so then that might be the
answer. Typically I haven't been too fond of DyanForms in the past (for a
couple of reasons), but if it could solve this issue it would definitely be
worth their use.

--
Rick Reumann

Reply via email to