Ok, this might be lengthy, but hopefully you will get my point after reading
it:)

This hypothetical I'm proposing isn't my actual use case, I'm creating an
example that is easier to work with even if not totally realistic.

The business requirement is the user needs to select a letter of alphabet
and then get back companies that start with that lettter so that they can
edit the Companies and the Divisions within each Company and within each
division be able to edit the Departments. All form ONE screen. So for
ultimate simplicity lets say it looks like:

//unkown num of companies
Company Name
Company Date
    //unknown num of divisions
     Division Name
     Division Date
            //unkown num of Departments
            Deapartment Name
            Department Date

All fields above are editable and all dates need to be validated to be in
correct input format.
Your domain layer already has in place several beans that it uses: Company,
Division, Department. All have String name and java.util.Date date fields.

So the user selects "letter D" from the drop down and submits.

Ok now walk me through what you would set up.

In my scenario it makes sense to make a call to the backend passing in the
letter "D" into: List getCompanies(String letter);

I'll now have in my Action a List of Companies, where each Company in the
List has a List of Divisions and within each Divison I have a List of
Departments.

Tell me how I'm going to easily set that up in my ActionForm so that I can
edit those date fields? Remember POJOs already exist that have a Date
property in them. You aren't suggesting the developer go through and create
all new POJOs with Strings in them to hold the Dates? Actually most of the
suggestions i've seen talk about addign String properties directly on the
form which in this case is impossible. You have no idea how many of each
type you would need, and then think of the work involved to put them back
into the nested objects in order to give the data back to the backend
methods for update.

Now let's even take a more mundane example. Let's take a "Person" object.
Before we even need to do any editing we have to display some users. Most
would agree that in OO programming its good to separate out responsibilities
so since a Person can have different Addresses (ie Work, Home, School, etc)
we typically have an Address object that would hold that data and maybe in
Person we'd have a Collection addresses to hold the Address objects. This
fits nicely with what our domain model gives us back when we make queries as
well. So displaying a List of Users we could also easily beneath each user
display their various addresses. Now what happens when you click on that
Person and you want to be able to edit that Person AND edit the different
addresses all from one screen? What are your properties going to be in your
PersonActionForm?  In this case since it's just a one level deep nest you
could create a List of HashMaps and hold each Address info in a HashMap, but
besides that being conceptually ugly, what if your Address object also had
some other data that needed to be updated (maybe a Collection of Phone
Numbers per address?).

I'm not so fond of cracking open each value object POJO and adding
birthDateAsString properties into them and then having them do coversions to
the underlying Date birthDate properties. Although that works it's really
not a very clean solution.

Does anyone know if the newer versions of Struts, Sruts TiBo, StrutsRocky
III, handle any of this? (I've been on the dark side doing some .NET stuff
so have been out of the loop for a while, but want to get back up to speed
with the latest buzz in the struts world).

--
Rick

Reply via email to