In my first attempt, I think that I got caught up in the "clever typecasting
may be needed if more than
one ActionForm class is accessed" problem. I'm trying to design a template
for a few generic reusable Action classes ( Corporate Info, Contact Info,
Location Info ).

I'll work up a simple prototype to identify what I'm missing.

Thanks...Steve

----- Original Message -----
From: "Ted Husted" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, July 24, 2001 9:25 AM
Subject: Re: code reuse


> From your description, it sounds like there could be an ancestor
> ActionForm common to the Order and Maintenance wizards. If that were the
> case, each could subclass that ActionForm, and the Corporate Info Action
> would then refer to the ancestor class, common to both wizards.
>
> In general, an Action does not need to be tightly coupled to a
> particular ActionForm. In fact, the coupling is rather loose. The Action
> itself is passed a reference to an ActionForm. Which ActionForm class is
> passed depends on the ActionMapping. There ~is~ a tight coupling between
> an ActionMapping and an ActionForm class, but the Actions themselves can
> be reused -- though some clever typecasting may be needed if more than
> one ActionForm class is accessed.
>
> It's important to remember that an Action can be used by any number
> of different ActionMappings. Whether or not they use the same ActionForm
> is up to the developer. The framework's design allows you to use a
> a different Action for each ActionForm, or a single Action for the
> entire
> application, or anything in between. (Praise be to Craig;-)
>
> -- Ted Husted, Husted dot Com, Fairport NY USA.
> -- Custom Software ~ Technical Services.
> -- Tel 716 737-3463.
> -- http://www.husted.com/about/struts/
>
>
> Stephen LeClair wrote:
> > One of the minor Order screens is the Corporate Info screen (mainly
> > address info)- it is designed to be a popup screen that can be called
> > from within the Order wizard or the Account Maintenance wizard. However,
> > it isn't implemented as an independent Action/Form because we don't know
> > how to make the Order Form AND the Account Mntc Form both reuse the
> > Corporate Info Form/Action. Specifically, we don't know how to implement
> > such that the Action class for Corporate Info can be reused by both the
> > Order and Account wizards. So, today the same fields are duplicated in
> > the two wizards and all the code is duplicated (ugly!).
> >
> > We can envision a wrapper form that contains other forms and uses a dot
> > notation in the JSPs to reference properties
> > (orderForm.corporateInfoForm.address) but how do the Action classes for
> > CorporateInfo get reused? There seems to be such tight coupling between
> > an ActionForm and an Action Class that I don't know how to achieve
> > reuse. I played with creating an IAddress Action interface that both the
> > Order and Account wizards could implement but got caught up in the
> > coupling issues.
>

Reply via email to