Thanks Craig, I go with you.

All I wanted was to avoid the duplication of information(in the form of
variables)  in JVM.
But your point about conversion of data type is totally agreeable.

So, I shall copy the values in Action class using BeanUtils.copyProperties()
to this new object(DTO).

Regards
Puneet Agarwal
----------------------------->
"Struts"..."Action"..."Struts in Action"..."Action in
Struts"...[possibly]"Action with Struts"...?
----- Original Message -----
From: "Craig R. McClanahan" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>; "Puneet
Agarwal" <[EMAIL PROTECTED]>
Sent: Monday, March 10, 2003 4:50 PM
Subject: Re: [Design Pattern]FormBean in Model Layer


>
>
> On Mon, 10 Mar 2003, Puneet Agarwal wrote:
>
> > Date: Mon, 10 Mar 2003 11:31:29 -0000
> > From: Puneet Agarwal <[EMAIL PROTECTED]>
> > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>,
> >      Puneet Agarwal <[EMAIL PROTECTED]>
> > To: Struts Users Mailing List <[EMAIL PROTECTED]>
> > Subject: Re: [Design Pattern]FormBean in Model Layer
> >
> > Yeah I am going to adopt this. I am not very sure of how exactly am I
going
> > to do that(at the moment). But yes it sounds too  good.
> >
>
> I do *not* agree with the idea of using an ActionForm (either DynaForm or
> not) as a DTO.  Using a custom interface gets around one of the problems
> (introducing a dependency on Struts), but not around the biggest one --
> the data types in a correctly written ActionForm are wrong for the
> business tier.
>
> In order to fulfill its purpose, the ActionForm properties must allow
> incorrect input to be redisplayed -- for example, a field that accepts an
> integer should allow the user to type "1a3" instead of "123" and have
> "1a3" redisplayed with the error message.  In order for this to work, the
> ActionForm property must be a String.  Yet, in a properly designed DTO,
> the property type would be "int".
>
> The best design practice is to create a separate DTO object (or DynaBean)
> with the correct data types, and use BeanUtils.copyProperties() to copy
> the values -- with appropriate conversions -- in your Action that accepts
> the form.  You know that you won't get conversion errors because they
> would have been caught in the validation checks that preceed calling the
> Action.
>
> > Thanks
> > Puneet Agarwal
>
> Craig McClanahan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


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

Reply via email to