You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by "Nestel, Frank" <fr...@coi.de> on 2000/06/20 09:44:33 UTC
AW: ActionForward Proposal (was Re: Change to Action.perform() s
ignature?)
Craig R. McClanahan wrote:
>
> David Geary wrote:
>
> > Robert.Claeson@brightid.se wrote:
> >
> > > Having the Action classes return a context-relative URI
> is almost exactly
> > > what I do in my framework, only that I don't return real
> URI's but rather
> > > logical view names (nulls are ok for the reason you
> cite). I then map
> > > those logical views to real URIs in a ViewProcessor class that the
> > > controller servlet use, after which the servlet does the
> forwarding.
> >
> > I too have a home-grown framework that does this. I'd like to see
> > ActionForward use a logical name instead of an actual URI.
> The logical name
> > could be mapped through entries in a forward.xml file. Not
> only does this
> > approach eliminate URI hard coding, but forward.xml has a
> nice design
> > symmetry with action.xml.
> >
> > If ActionForward stays the way it is, I will wind up
> implementing my own
> > ActionForward factory that instantiates ActionForward
> instances given a
> > logical name. The factory will look up the actual URI from
> an XML file and
> > use that to instantiate ActionForward instances. I would
> imagine that other
> > developers like Robert will do something similar, so we
> might as well have it
> > in Struts to begin with.
> >
>
> I haven't updated the documentation yet to reflect it, but I
> would submit that
> the current code base does in fact support logical lookup of
> forward entries.
>
> Consider the action.xml entry for the "/logon" path.
> Currently, it has the
> following contents:
>
> <action path="/logon" ... other attributes ... >
> <forward name="logon" path="/logon.jsp"/>
> <forward name="success" path="/mainMenu.jsp"/>
> </action>
>
> The nested <forward> elements are used to create a lookup
> table for ActionForward
> entries, based on the logical name you have assigned. Thus,
> in the action class
> after you validate that the user credentials are correct, you execute:
>
> return (actionMapping.findForward("success"));
>
> to do a logical lookup on the name "success" -- which ends up
> forwarding to
> /mainMenu.jsp with the configuration file as shown. You can
> have as many
> <forward> elements as you want, using logical names that are
> private to this
> particular <action> entry. The names of the forwards for
> each action mapping do
> not have to be the same, which makes this approach nicer than
> extending the
> ActionMappingBase class with additional properties.
>
> I'm also going to be adding a capability for global logical
> forwards -- for
> things that are used across multiple action classes. You'll
> be calling
> servlet.findForward() instead of actionMapping.findForward()
> to grab those, but
> it's the same idea -- as many logical names as you want.
>
> >
> > david
>
> Craig McClanahan
>
>
Those forwards sound very good. On top of that
one could easily have an tag <struts:forward name="logon">
allowing to work with virtual URI's in JSP as well.
Global forwards are nice either. Would it make sense that
the ActionMapping.findForward(...) tries an Servlet.findForward(...)
in case it does not find the mapping in it's own tables?
RE: AW: ActionForward Proposal (was Re: Change to Action.perform() signature?)
Posted by David Chisholm <Da...@i2.com>.
> -----Original Message-----
> From: Craig R. McClanahan [mailto:Craig.McClanahan@eng.sun.com]
> Sent: Thursday, June 29, 2000 8:15 PM
> To: struts-dev@jakarta.apache.org
> Subject: Re: AW: ActionForward Proposal (was Re: Change to
> Action.perform() signature?)
>
>
> David Chisholm wrote:
>
> > > -----Original Message-----
> > > From: Craig R. McClanahan [mailto:Craig.McClanahan@eng.sun.com]
> > > Sent: Thursday, June 29, 2000 7:52 PM
> > > To: struts-dev@jakarta.apache.org
> > > Subject: Re: AW: ActionForward Proposal (was Re: Change to
> > > Action.perform() signature?)
> > >
> > >
> > > "Nestel, Frank" wrote:
> > >
> > > > Those forwards sound very good. On top of that
> > > > one could easily have an tag <struts:forward name="logon">
> > > > allowing to work with virtual URI's in JSP as well.
> > > >
> > >
> > > I just added this tag, and a corresponding <struts:include>
> tag that looks
> > > up the logical name and includes the page at the corresponding
> > > actual path,
> > > at this point in the page.
> > >
> > > >
> > > > Global forwards are nice either. Would it make sense that
> > > > the ActionMapping.findForward(...) tries an Servlet.findForward(...)
> > > > in case it does not find the mapping in it's own tables?
> > >
> > > Doing this sounds like it would be useful. An interesting
> implication is
> > > that the ActionMapping class would have to know how to find either the
> > > ActionServlet that owns it, or the global ActionForwards
> collection. The
> > > latter would probably be safer.
> > >
> >
> > I think it's useful as a safety net and for situations were you want to
> > override a default global ActionForward with one locale to the
> > ActionMapping.
> >
>
> It also means you can program your Action without caring whether
> your forwarding
> entry was registered as local or global. This will reduce errors.
>
> A change to do this will be checked in momentarily.
>
> >
> > Btw, would it be useful to the forward tag to forward to
> actions too? For
> > example <struts:forward action="myActionName"/>.
> >
>
> As currently written, <struts:forward> goes to the new page
> immediately, just
> like <jsp:forward> does. Given that, I'm not sure it really
> makes sense to
> forward to an action. But maybe we want to extend the
> <struts:link> tag so that
> you can generate hyperlinks to pages based on the logical name?
>
I'm not sure if this is useful or not. On the one hand, you can de-couple
the url of a link to a static page (static in the sense that an Action is
not executed prior to the page), on the other hand why configure an
ActionForward for an Action if the Action does not forward to it?
Maybe you should wait until someone has a real need for it before adding it?
> (It doesn't really help much on actions because the "logical"
> name of an action
> is in fact the path itself).
>
Understood.
David
Re: AW: ActionForward Proposal (was Re: Change to Action.perform()
signature?)
Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
David Chisholm wrote:
> > -----Original Message-----
> > From: Craig R. McClanahan [mailto:Craig.McClanahan@eng.sun.com]
> > Sent: Thursday, June 29, 2000 7:52 PM
> > To: struts-dev@jakarta.apache.org
> > Subject: Re: AW: ActionForward Proposal (was Re: Change to
> > Action.perform() signature?)
> >
> >
> > "Nestel, Frank" wrote:
> >
> > > Those forwards sound very good. On top of that
> > > one could easily have an tag <struts:forward name="logon">
> > > allowing to work with virtual URI's in JSP as well.
> > >
> >
> > I just added this tag, and a corresponding <struts:include> tag that looks
> > up the logical name and includes the page at the corresponding
> > actual path,
> > at this point in the page.
> >
> > >
> > > Global forwards are nice either. Would it make sense that
> > > the ActionMapping.findForward(...) tries an Servlet.findForward(...)
> > > in case it does not find the mapping in it's own tables?
> >
> > Doing this sounds like it would be useful. An interesting implication is
> > that the ActionMapping class would have to know how to find either the
> > ActionServlet that owns it, or the global ActionForwards collection. The
> > latter would probably be safer.
> >
>
> I think it's useful as a safety net and for situations were you want to
> override a default global ActionForward with one locale to the
> ActionMapping.
>
It also means you can program your Action without caring whether your forwarding
entry was registered as local or global. This will reduce errors.
A change to do this will be checked in momentarily.
>
> Btw, would it be useful to the forward tag to forward to actions too? For
> example <struts:forward action="myActionName"/>.
>
As currently written, <struts:forward> goes to the new page immediately, just
like <jsp:forward> does. Given that, I'm not sure it really makes sense to
forward to an action. But maybe we want to extend the <struts:link> tag so that
you can generate hyperlinks to pages based on the logical name?
(It doesn't really help much on actions because the "logical" name of an action
is in fact the path itself).
>
> David
Craig
RE: AW: ActionForward Proposal (was Re: Change to Action.perform() signature?)
Posted by David Chisholm <Da...@i2.com>.
> -----Original Message-----
> From: Craig R. McClanahan [mailto:Craig.McClanahan@eng.sun.com]
> Sent: Thursday, June 29, 2000 7:52 PM
> To: struts-dev@jakarta.apache.org
> Subject: Re: AW: ActionForward Proposal (was Re: Change to
> Action.perform() signature?)
>
>
> "Nestel, Frank" wrote:
>
> > Those forwards sound very good. On top of that
> > one could easily have an tag <struts:forward name="logon">
> > allowing to work with virtual URI's in JSP as well.
> >
>
> I just added this tag, and a corresponding <struts:include> tag that looks
> up the logical name and includes the page at the corresponding
> actual path,
> at this point in the page.
>
> >
> > Global forwards are nice either. Would it make sense that
> > the ActionMapping.findForward(...) tries an Servlet.findForward(...)
> > in case it does not find the mapping in it's own tables?
>
> Doing this sounds like it would be useful. An interesting implication is
> that the ActionMapping class would have to know how to find either the
> ActionServlet that owns it, or the global ActionForwards collection. The
> latter would probably be safer.
>
I think it's useful as a safety net and for situations were you want to
override a default global ActionForward with one locale to the
ActionMapping.
Btw, would it be useful to the forward tag to forward to actions too? For
example <struts:forward action="myActionName"/>.
David
Re: AW: ActionForward Proposal (was Re: Change to Action.perform()
signature?)
Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
"Nestel, Frank" wrote:
> Those forwards sound very good. On top of that
> one could easily have an tag <struts:forward name="logon">
> allowing to work with virtual URI's in JSP as well.
>
I just added this tag, and a corresponding <struts:include> tag that looks
up the logical name and includes the page at the corresponding actual path,
at this point in the page.
>
> Global forwards are nice either. Would it make sense that
> the ActionMapping.findForward(...) tries an Servlet.findForward(...)
> in case it does not find the mapping in it's own tables?
Doing this sounds like it would be useful. An interesting implication is
that the ActionMapping class would have to know how to find either the
ActionServlet that owns it, or the global ActionForwards collection. The
latter would probably be safer.
Craig