Hi Mark

I had a similar situation adn what i did is i made a the parent action form an 
Abstract class. and say i have twi action forms form1 and form 2 which extends this 
Abstract class. Then i have different getData() for these two form to populate the 
form. So i can simple use the getters and setters of the abstract class to set the 
common properties.

I hope this is what you are looking for

thank you
Manoj Mathew
(It took me 30  years to look this good :) )


-----Original Message-----
From: Mark Jones [mailto:[EMAIL PROTECTED]
Sent: Saturday, February 21, 2004 10:41 PM
To: Struts User
Subject: [Newbie] Is it worth subclassing your own Action and ActionForm
classes to attain code re-use?


My application allows a user to make various different types of bookings for
a (fictional!!!) hospital and logs them in a database. Each type of booking
has a set of common properties but also different ones depending on the type
of booking being made.

I have divided my classes into a BookingAction and BookingActionForm
superclass and subclasses (such as AmbulanceBookingAction and
AmbulanceBookingActionForm) because I anticipate creating other subtypes of
BookingAction that use the same properties in the BookingAction class but
not in the AmbulanceBookingAction subclass. This initially seemed to me to
be in keeping with programming for code re-use and extensibility.

My problem with this is, if a user submits a form which posts its data via
the ActionServlet to the AmbulanceBookingAction subclass, how would I ensure
the BookingAction class did its stuff? Would it be better / easier to use
separate, non-derived (from my superclasses) Actions and ActionForms to
handle each type of booking and not subclass BookingAction and
BookingActionForm (even though I would be repeating the some of the same
properties common to each different type of booking)?

I am concerned, though, not to lose points for not reusing code. It just
seems to me, though, that trying to divvy the handling of the form data via
inheritance is too complicated and / or unnecessary.

In what circumstances might you want to subclass your own Action class and,
if you did, how would you handle/inherit the form data? Would you just use
different subclasses of your Action but just one ActionForm for each Action?

What is the best way for me to implement this problem? (Or have I answered
my own question?! ;0) )

Thanks for indulging me!

Mark


---------------------------------------------------------------------
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