You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Darrel Riekhof <ri...@lvcm.com> on 2002/12/23 09:44:52 UTC
Presentation Forms to Business Views
Just getting started with struts, going through the oreilly book. I've
implemented my presentation layer with struts, and now I'm working on
interfacing it with my business layer. The book recommends converting your
form classes to DTO view classes before passing the data to the business
tier to avoid coupling presentation and business layers.
Makes sense, but it is such a royal pain in the a** doing the conversion,
and the form and view classes are so similar. Anyone know of a clever
strategy for dealing with this issue? I was thinking each one could use
some kind of dynamic proxy that forwards the gets and sets to a lower level
object--they both could use this object to store their data. Then the
conversion would just be setting this object in the DTO view class. Think
this is overkill?
Darrel
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Presentation Forms to Business Views
Posted by Eddie Bush <ek...@swbell.net>.
If you're using Struts, you have it. Struts relies on it.
Darrel Riekhof wrote:
> Cool, didn't know about BeanUtils.
>
> I've got tomcat 4.1.18 and struts 1.1 b2. Do I already have BeanUtils
> somewhere? I see its in the Jakarta Commons package, should I grab a
> certain version of it?
>
> Darrel
>
> Eddie Bush wrote:
>
>> BeanUtils.populate(dtoObject, formObject);
>>
>> How is that a big PITA? If the "core" object is actually storing
>> data in the correct types, you'll lose user input when conversions
>> fail. The goal of most folks is to present the user with their
>> exact, incorrect input for correction. That's why the methodology
>> you speak of is suggested.
>>
>> For object with the same properties (names) that have different
>> types, use BeanUtils. If you find yourself in a situation where you
>> wish to copy objects with the same properties (names) that are of the
>> same types, use PropertyUtils. You can your PITA conversions down to
>> a single line of code.
>>
>> Darrel Riekhof wrote:
>>
>>> Just getting started with struts, going through the oreilly book. I've
>>> implemented my presentation layer with struts, and now I'm working on
>>> interfacing it with my business layer. The book recommends
>>> converting your
>>> form classes to DTO view classes before passing the data to the
>>> business
>>> tier to avoid coupling presentation and business layers.
>>>
>>> Makes sense, but it is such a royal pain in the a** doing the
>>> conversion,
>>> and the form and view classes are so similar. Anyone know of a clever
>>> strategy for dealing with this issue? I was thinking each one could
>>> use
>>> some kind of dynamic proxy that forwards the gets and sets to a
>>> lower level
>>> object--they both could use this object to store their data. Then the
>>> conversion would just be setting this object in the DTO view class.
>>> Think
>>> this is overkill?
>>>
>>> Darrel
>>
--
Eddie Bush
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Presentation Forms to Business Views
Posted by Darrel Riekhof <ri...@lvcm.com>.
Cool, didn't know about BeanUtils.
I've got tomcat 4.1.18 and struts 1.1 b2. Do I already have BeanUtils
somewhere? I see its in the Jakarta Commons package, should I grab a
certain version of it?
Darrel
Eddie Bush wrote:
> BeanUtils.populate(dtoObject, formObject);
>
> How is that a big PITA? If the "core" object is actually storing data
> in the correct types, you'll lose user input when conversions fail.
> The goal of most folks is to present the user with their exact,
> incorrect input for correction. That's why the methodology you speak
> of is suggested.
>
> For object with the same properties (names) that have different types,
> use BeanUtils. If you find yourself in a situation where you wish to
> copy objects with the same properties (names) that are of the same
> types, use PropertyUtils. You can your PITA conversions down to a
> single line of code.
>
> Darrel Riekhof wrote:
>
>> Just getting started with struts, going through the oreilly book. I've
>> implemented my presentation layer with struts, and now I'm working on
>> interfacing it with my business layer. The book recommends
>> converting your
>> form classes to DTO view classes before passing the data to the business
>> tier to avoid coupling presentation and business layers.
>>
>> Makes sense, but it is such a royal pain in the a** doing the
>> conversion,
>> and the form and view classes are so similar. Anyone know of a clever
>> strategy for dealing with this issue? I was thinking each one could use
>> some kind of dynamic proxy that forwards the gets and sets to a lower
>> level
>> object--they both could use this object to store their data. Then the
>> conversion would just be setting this object in the DTO view class.
>> Think
>> this is overkill?
>>
>> Darrel
>>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Presentation Forms to Business Views
Posted by Eddie Bush <ek...@swbell.net>.
BeanUtils.populate(dtoObject, formObject);
How is that a big PITA? If the "core" object is actually storing data
in the correct types, you'll lose user input when conversions fail. The
goal of most folks is to present the user with their exact, incorrect
input for correction. That's why the methodology you speak of is suggested.
For object with the same properties (names) that have different types,
use BeanUtils. If you find yourself in a situation where you wish to
copy objects with the same properties (names) that are of the same
types, use PropertyUtils. You can your PITA conversions down to a
single line of code.
Darrel Riekhof wrote:
>Just getting started with struts, going through the oreilly book. I've
>implemented my presentation layer with struts, and now I'm working on
>interfacing it with my business layer. The book recommends converting your
>form classes to DTO view classes before passing the data to the business
>tier to avoid coupling presentation and business layers.
>
>Makes sense, but it is such a royal pain in the a** doing the conversion,
>and the form and view classes are so similar. Anyone know of a clever
>strategy for dealing with this issue? I was thinking each one could use
>some kind of dynamic proxy that forwards the gets and sets to a lower level
>object--they both could use this object to store their data. Then the
>conversion would just be setting this object in the DTO view class. Think
>this is overkill?
>
>Darrel
>
--
Eddie Bush
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>