struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laurie Harper <>
Subject Re: Best Practices for reusability?
Date Fri, 16 Mar 2007 17:57:10 GMT
Piwoni, Andre wrote:
> I'm working on a large and complex web application. One of the things
> that bothers me is a WizardAction with one ActionForm working on
> multiple JSP pages. All of these JSP pages have hardcoded action URLs
> that map to struts actions. I'd like to re-use several JSP pages form
> this wizard in another wizard but it is difficult because of hardcoded
> action URLs and wizard specific ActionForm being used. Best practices
> that I have read recommends for "clarity and easy maintenance, the
> strategy for large applications should be to have one-to-one mapping
> between JSP pages and Action classes." This makes sense and would make
> it easier to reuse JSP pages in various wizards; however, hardcoded
> action URLs, correct me if I'm wrong, have to go away.

I think you misinterpreted that sentence... It's saying one JSP should 
always map to exactly one action, in which case it wouldn't be a problem 
to hard-code it. But you're right, you often do want to re-use portions 
of your templates/JSPs.

> I can think of two ways I could implement wizards that re-use JSP page
> with a separate Action and Form.
> 1) By going to re-used JSP page from two or more different JSP pages and
> subsequently return to the calling JSP page that implements such wizard.
> But what is the best way to return collected data?
> 2) By having dynamic action URLs in re-used JSP pages. Not sure about
> details yet.

Well, if you need to collect the same set of data as part of two 
different process flows, you probably want to just invoke the same 
wizard implementation in both cases, but include some invocation context 
about where you invoked it from. Then have your wizard return the data 
it's collected to that action for final processing.

Also consider Tiles / JSP includes, custom tag libraries and other forms 
of view reuse. Sometimes the best approach is to factor out the parts of 
your wizard JSPs that you need to use in more than one place and just 
have two (or more) views that use those factored-out pieces.


> It also seems that Action Chaining described under this link,
> , may be helpful as well.
> Any thoughts or suggestions for implementing wizards with re-usable JSP
> pages are greatly appreciated!
> Andre Piwoni
> ------------------------------------------------------------------------------
> This email is confidential and may be legally privileged.
> It is intended solely for the addressee. Access to this email by anyone else, unless
expressly approved by the sender or an authorized addressee, is unauthorized.
> If you are not the intended recipient, any disclosure, copying, distribution or any action
omitted or taken in reliance on it, is prohibited and may be unlawful. If you believe that
you have received this email in error, please contact the sender, delete this e-mail and destroy
all copies.
> ==============================================================================

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message