I'm sure I've seen some notes on this in the Struts resources
to get common behaviour
Create your own action class that extends the struts Actions to hold common
function calls
Have your specific actions extend this default Action
You can further subclass the default action e.g. we have a subclass
DefaulCRUDAction with specific behaviours

Some where I've seen a variation on this where the base class action perform
calls a different method on each specific action
Ah found it see
Ted Husted's Struts Catalog
Quote ....."
Use a Base Action for your application
Often, the Actions in your application will need to perform some basic
tasks. To ensure these tasks are implement consistently, create a base
Action for the others in your application to subclass.  

If key tasks needs to be completed in each Action's perform() method, a good
approach is to create a new abstract methods for your subclasses to use in
lieu of perform(). The base Action class does its business, and if all is
well, then returns the result of the new method. This allows you to change
the signature of your new method, if there is ever any reason for that, and
provides a cleaner flow. 

    public ActionForward perform(ActionMapping mapping,
                 ActionForm form,
                 HttpServletRequest request,
                 HttpServletResponse response)
    throws IOException, ServletException { 

        // Application specific behaviour
        // if everything is kosher call subclass 

        return ( performAction(mapping,form,request,response, myParameter )
)
   } 

   where performAction is an abstract method of the base class. 

..."
-----Original Message-----
From: Ronald Haring [mailto:[EMAIL PROTECTED]]
Sent: 05 March 2002 12:15
To: '[EMAIL PROTECTED]'
Subject: design question


Hi all,

I've studied the design paper that Ted has put up at his site
(http://husted.com/about/scaffolding/strutByStrut.htm) . Very clear
explanation Ted, it only left me with one question. In your paper you state
that every form should have its own action. However for my last project (and
my first struts project) I used the same action for most of the forms.

This action would then decide based upon a navigate field in the form :
- which formBean to create and populate
- which mapping to return

based on a large if (navigation.equals("<something>")) tree.

I submitted always to the same form, so that this ControllerAction could
perform some default behavious I liked to execute (e.g. dynamic change of
language, default SQLException handling) and that all the navigation was in
the same class. 
Somehow I have the feeling that this is not the way to go.

However on the detail screens there are links to other detail screens. These
are simple links like <a href=javascipt:goSubmit('showFirstDetailsScreen')>
... <a href=javascipt:goSubmit('showSecondeDetailsScreen')> etc etc. (where
goSubmit is a javascript function that will fill the navigate field with the
given value and then submit the form). If I want a action for every form how
should I set this so that showFirstDetailsScreen will go to the right
action, without using multiple forms (since this really screws up the html
lay-out)


Gr
Ronald 


Furore B.V.
Rijswijkstraat 175-8
Postbus 9204
1006 AE Amsterdam
tel. (020) 346 71 71
fax. (020) 346 71 77

----------------------------------------------------------------------------
---------------
The information transmitted is intended only for the person
or entity to which it is addressed and may contain confidential
and/or privileged material. Any review, retransmission,
dissemination or other use of, or taking of any action in
reliance upon, this information by persons or entities other
than the intended recipient is prohibited. If you received
this in error, please contact the sender and delete the material
from any computer
----------------------------------------------------------------------------
---------------



***************************************************************************
This email message contains confidential information for the above addressee only.  If 
you are not the intended addressee you must not disclose or use the information in any 
manner whatsoever.

Any opinion or views contained in this email message are those of the sender, do not 
represent those of the Company in any way and reliance should not be placed upon its 
contents.

Unless otherwise stated this email message is not intended to be contractually 
binding.  Where an Agreement exists between our respective companies and there is 
conflict between the contents of this email message and the Agreement then the terms 
of that Agreement shall prevail.

Abbey National Treasury Services plc. Registered in England. Registered Office:  Abbey 
House, Baker Street, London NW1 6XL.  Company Registration No: 2338548.  Regulated by 
the FSA
***************************************************************************


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

Reply via email to