Struts2 provides automatic type conversion facilities, which makes life
much easier in these cases. With Struts1, however, you need to handle
the type conversion yourself. You can make this less painful by using
the validation framework (so that by the time you get to doing the type
conversion, you already know the data is in the right format).
There are, of course, varying opinions on how/where to place such type
conversion logic. My preference is to handle it in the action, either
directly or via a helper class. YMMV.
L.
Viplav Kallepu wrote:
Thanks for the reply.. but the variables in the actionform's datatype will
be string and DTO's will be corresponding oracle dataType. I am not able to
understand the advantage of writing the interface. May be I am missing the
concept. Actually my doubt is whether I can write type conversion codes in
Action Class and pass the variables to DTO or should I write another class
where datatype conversions are made. My understanding says we shouldn't
write type conversion code in Action Class . Even if I use "
BeanUtils.copyProperties" where should I place this code. Please help
me.
On 7/13/07, Yoge <[EMAIL PROTECTED]> wrote:
Write an interface with all the methods in your actionform. Your DTO bean
class and actionform class should implement the interface. Now you dont
need
to do any type casting in your action class.
Sorry if my understanding is wrong.
--Yoge
On 7/13/07, Viplav Kallepu <[EMAIL PROTECTED]> wrote:
>
> Hi All,
>
> I am new to struts and I am using struts 1.3.8. I am using a bean class
> for
> every table in oracle as a Data Transfer Object and a actionform for
every
> jsp. Now my problem is I have to do data type conversion from my
> actionform
> to DTO and DTO to actionform, for example I have date in my jsp
which is
> split into three drop down fileds(year,month,day) and in the DTO its a
> single field. How can manage this. Is it a standard that we can do
data
> type conversions in Action Class.?? I was trying to find out best
> practice.
> Please help me in sorting out the issue. Is there any design changes I
> have
> to do??
>
>
> --
> Regards
> Viplav Kallepu
>
--
Yoge,
AdventNet, Inc.
925-965-6528
[EMAIL PROTECTED]
site24x7.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]