You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Rajesh Kanade <rk...@bigates.com> on 2002/10/22 09:00:44 UTC
Duplication of code in Business objects and Action forms
Hi All
I am new to Struts so please bear with me.
We have started implementing a new product using struts.
Now I do see that I need to have getter /setter methods declared on both my
business objects as well as Action form.
So for e.g if I had a User business object which encapsulates the entire
business login for my system user.
Now I will have UserForm class also which will have all the getter/setter
methods of ny User Object so as to faciliate the CRUD operation from the
browser.
If something changes I need to go and change it in both the places.
Is there any way to over come this problem.
Any help would be greatly appreciated.
Rajesh Kanade
Re: Duplication of code in Business objects and Action forms
Posted by Ronald Rotteveel <r....@its.tudelft.nl>.
I'm not using Struts for a very long time now, but I think this is NOT the
way to do this.
In your ActionForm bean called User I would put the getter/setter methods.
In your UserBO (User Business Object) I would put the methods that make use
of the UserDAO (User Data Access Object). The UserBO is only for handling
the business logic in your form/application. The UserDAO actually executes
the real SQL queries or XML update functions.
So, User extends ActionForm and is really a simple mapping of your form in
your application.
In your Action class (belonging to this User form) you map the User bean and
give it as an argument with any function of your UserBO object which will
execute the desired action (update/create/delete etc.).
Hope I helped you a bit. Maybe other people have better solutions, but this
is the way I handle actions.......
Good luck........
Regards,
Ronald
----- Original Message -----
From: "Rajesh Kanade" <rk...@bigates.com>
To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
Sent: Tuesday, October 22, 2002 9:00 AM
Subject: Duplication of code in Business objects and Action forms
> Hi All
>
> I am new to Struts so please bear with me.
>
> We have started implementing a new product using struts.
>
> Now I do see that I need to have getter /setter methods declared on both
my
> business objects as well as Action form.
> So for e.g if I had a User business object which encapsulates the entire
> business login for my system user.
> Now I will have UserForm class also which will have all the getter/setter
> methods of ny User Object so as to faciliate the CRUD operation from the
> browser.
>
>
> If something changes I need to go and change it in both the places.
>
> Is there any way to over come this problem.
>
> Any help would be greatly appreciated.
>
> Rajesh Kanade
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>