I know exactly what you mean. What we decided on as a standard I store cats
and dogs as Lists and then have getter/setter methods for Array objects
which convert to/from a List on the fly.

I'm not sure if this adheres to OO principles but it's serves our purpose
well.

Zoran 

> Lets assume you want to be a good OO developer and you are designing
> an application to handle CRUD stuff for a "Person." Lets say this
> Person can own Cats and Dogs. So person might look like...
> 
> Person
> ------
> int personId
> String personName
> List dogs; //list of Dog objects
> List cats; //list of Cat objects
> 
> Your backend persistence layer of choice knows how to deal with this
> Person. When it goes to insert/update a Person it knows how to update
> the PersonDog and PersonCat tables with respective dog and cat ids.
> 
> Where I always run into problems is how to best handle this kind of
> stuff on the front end in Struts for multi select options (and also
> using multibox with checkboxes).
> 
> The dilemma first is "What should your PersonActionFrom hold in
> relation to Cats and Dogs when all you need to capture is Dog/Cat Ids
> on you form?"
> 
> The standard practice often espoused is your ActionForm should only be
> interested in capturing the inputted data - so in this case it would
> be String[] catIds,  String[] dogIds. This is what I'm currently
> doing, but it then requires an extra conversion to convert these ids
> into "Dog" and "Cat" objects so that I could pass a full "Person"
> object to the backend/service layer.  (You also have to convert going
> back the other way as well for when you want to do an update.)
> Typically I use BeanUtils to do my copying of properties from
> ActionForm --> ValueObject and back the other direction as well.
> Currently I'm having to use special helper covert methods that use a
> combination of BeanUtils and the custom conversions for stuff like
> taking a String[] dogIDs and building Dog objects from them.
> 
> Just curious on approaches other people use and how do other
> frameworks, like JSF, deal with this since they don't use ActionForms.
> (For example if I have a "Person" backing bean with "Cats" and "Dogs"
> in it, and my multiselect list allows me to choose dogs and cats, how
> do these get updated in the backing bean.
> 
> --
> Rick



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to