struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Witbeck, Shane" <Shane.Witb...@bankofamerica.com>
Subject RE: Design Question - same action, many jsps/views
Date Mon, 28 Jul 2003 19:02:09 GMT
Using tiles and 1.1 I currently am working on a project which uses
DispatchAction extensively. In the action classes which extend
DispatchAction I have 3 methods:

1. init() - which initializes form data, etc.
2. update() - which does some business logic based on a form selection.
3. submitForm() - which does some validation and other associated logic on
the completed data.

In the struts-config.xml I have 3 forwards defined:

1. success - defaults to the jsp associated with the action
2. failure - same jsp as above if there is a validation failure
3. nextAction - fowards to the next action in the flow ...usually something
like /action/Action?method=init

Maybe this will give you some idea for your design?

HTH,

Shane

-----Original Message-----
From: Hue Holleran [mailto:struts-user-hueh@openAction.net]
Sent: Monday, July 28, 2003 1:40 PM
To: Struts Users Mailing List
Subject: RE: Design Question - same action, many jsps/views


Hi Brian,

Yes - I can see your point. Whenever I need to do this (with multi-page
forms, for instance - where the "Next" button should forward to the next
page) - I use a property on the form, from memory it might be "currentPage"
(which is numeric for me) that is held as a hidden form property that is
used to do the "from" logic you are describing. Ok, this was done
specifically as we are using tiles, as I believe this may confuse the
getRequestURI() return value(?).

The alternative may be to use the dispatcher to define a specific entry
point in your action that can call some generic code (i.e. that presumably
you're now concerned about duplicating - and I agree with your concerns) -
and then forward to the correct forward?

Alternatively the struts-workflow extensions may provide additional clues
for you on how this may be done. From memory, we were discouraged from using
this as it had several pre-requisites, like appending something to every
action and actions needing to work in a particular way that was too much
work for us (and I think there some issues using it with tiles?). I think
the new version integrates much better with 1.1 so this may be worth a look,
too?

URL in case you don't have it: http://www.livinglogic.de/Struts

Hue.

> -----Original Message-----
> From: Brian McSweeney [mailto:brian.mcsweeney@aurium.net]
> Sent: 28 July 2003 16:27
> To: 'Struts Users Mailing List'
> Subject: RE: Design Question - same action, many jsps/views
>
>
> Hi Hue,
>
> That's definitely one way to go, but the disadvantage that
> I see of using this way is that you presumably have to hard code into
> the action, some way of identifying where the request came from. Perhaps
>
> something like:
>
> 	String input = request.getRequestURI();
>
> 	if(input.equalsIgnorCase("inputpath1")
> 		return (mapping.findForward("page1"));
>
> 	else if(input.equalsIgnorCase("inputpath2");
> 		return (mapping.findForward("page2"));
>
> 	else if(input.equalsIgnorCase("inputpath3");
> 		return (mapping.findForward("page3"));
>
>
> The previous new action mapping idea means you don't have to do
> this I think, which might make it a better solution. What do you
> think?
>
> I'm not sure though, and thanks very much for the help.
> Brian
>
> -----Original Message-----
> From: Hue Holleran [mailto:struts-user-hueh@openAction.net]
> Sent: 28 July 2003 16:11
> To: Struts Users Mailing List
> Subject: RE: Design Question - same action, many jsps/views
>
> Hi Brian,
>
> Why not use different named forwards for the action and access each one
> from
> the action with a:
>
> {
> ...
> return (mapping.findForward("page1/page2/page3"));
> }
>
> In s-c:
>
> <action path="/myAction"
>   type="<FQ Class>"
>   name="<bean>"
>   ...
> >
> <forward name="page1" path="/page1.jsp"/>
> <forward name="page2" path="/page2.jsp"/>
> <forward name="page3" path="/page3.jsp"/>
> </action>
>
> Hue.
>
> > -----Original Message-----
> > From: Brian McSweeney [mailto:brian.mcsweeney@aurium.net]
> > Sent: 28 July 2003 10:39
> > To: struts-user@jakarta.apache.org
> > Subject: Design Question - same action, many jsps/views
> >
> >
> > Hi all,
> >
> > I've come across a situation which I'm not sure how to handle with
> > struts.
> > I have an action which, depending on from which page it's called,
> > should forward to different jsps pages.
> >
> > Currently, for each resultant jsp, I create a new action with the
> exact
> > same
> > logic code inside which forwards to the right jsp.
> >
> > I'm just not sure if this is the right way to do it, because it's
> > replication of code.
> > An alternative might be to switch on the input path of the request and
> > forward to
> > The right jsp, but I'm not sure if this is right either. This has to
> > have come up
> > before, so I'm looking for a best practice solution.
> >
> > What do you guys reckon?
> >
> > Thanks,
> > Brian
> >
> > ---
> > Incoming mail is certified Virus Free.
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.504 / Virus Database: 302 - Release Date: 24/07/2003
> >
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.504 / Virus Database: 302 - Release Date: 24/07/2003
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.504 / Virus Database: 302 - Release Date: 24/07/2003
>
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.504 / Virus Database: 302 - Release Date: 24/07/2003


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message