struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brian McSweeney" <brian.mcswee...@aurium.net>
Subject RE: Design Question - same action, many jsps/views
Date Mon, 28 Jul 2003 15:26:52 GMT
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


Mime
View raw message