You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Kulp, Arian" <AK...@Aegonusa.com> on 2002/08/02 17:31:42 UTC

Forwards in strugs-config.xml

I'm afraid I can see the answer, but wanted to be sure.  In the
strugs-config.xml you can specify global-fowards.  This seems like a great
way to set a logical name for the view resources.  Unfortunately it is
rather redundant to define "logon" as "/logon.jsp" in global-forwards, just
to redefine it as "success" in a mapping for /logoff later on.  It would be
nice to be able to make action forwards be relative to an already-defined
global forward.  I hope this is making sense!

For example (hypothetical):

    <global-forwards>
            <forward name="logon" path="/logon.jsp"/>
            <forward name="home" path="/index.jsp"/>
    </global-forwards>

    <action
            path="/logoff"
            type="com.carefinder.action.LogoffAction">
            <forward name="success" gforward="logon"/>
    </action>

In this case, specifying a gforward of "success" in the Action Servlet,
would resolve to the global-forward defined for "logon" which would be
"/logon.jsp."  Otherwise later when I put my JSP's into my WEB-INF folder, I
need to remember to change it in the global-forward and all action forwards
that use them.  Is this already possible in some creative (or directly
supported) way?  Is this just not a good idea for some reason I'm not
thinking of?  Any comments appreciated (well friendly ones anyway...  ;-) )!

Thanks!
-Arian

Arian Kulp
Java Developer
AEGON Financial Partners
akulp@aegonusa.com
319.298.4117




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Forwards in strugs-config.xml

Posted by Joe Germuska <Jo...@Germuska.com>.
You don't need to redefine global forwards in action-mappings.  In an 
action class, when you call "mapping.findForward()", if there is no 
local forward with the appropriate name, it will look through global 
forwards.

So, in "com.carefinder.action.LogoffAction", you could call 
'mapping.findForward("logon")' and everything would work.

Get it?

Joe

PS Just 'cause it's so short, here's the code from ActionMapping.java:

     /**
      * <p>Find and return the <code>ForwardConfig</code> instance defining
      * how forwarding to the specified logical name should be handled.  This is
      * performed by checking local and then global configurations for the
      * specified forwarding configuration.  If no forwarding configuration
      * can be found, return <code>null</code>.</p>
      *
      * @param name Logical name of the forwarding instance to be returned
      */
     public ActionForward findForward(String name) {

         ForwardConfig config = findForwardConfig(name);
         if (config == null) {
             config = getApplicationConfig().findForwardConfig(name);
         }
         return ((ActionForward) config);

     }



At 10:31 AM -0500 2002/08/02, Kulp, Arian wrote:
>I'm afraid I can see the answer, but wanted to be sure.  In the
>strugs-config.xml you can specify global-fowards.  This seems like a great
>way to set a logical name for the view resources.  Unfortunately it is
>rather redundant to define "logon" as "/logon.jsp" in global-forwards, just
>to redefine it as "success" in a mapping for /logoff later on.  It would be
>nice to be able to make action forwards be relative to an already-defined
>global forward.  I hope this is making sense!
>
>For example (hypothetical):
>
>     <global-forwards>
>             <forward name="logon" path="/logon.jsp"/>
>             <forward name="home" path="/index.jsp"/>
>     </global-forwards>
>
>     <action
>             path="/logoff"
>             type="com.carefinder.action.LogoffAction">
>             <forward name="success" gforward="logon"/>
>     </action>
>
>In this case, specifying a gforward of "success" in the Action Servlet,
>would resolve to the global-forward defined for "logon" which would be
>"/logon.jsp."  Otherwise later when I put my JSP's into my WEB-INF folder, I
>need to remember to change it in the global-forward and all action forwards
>that use them.  Is this already possible in some creative (or directly
>supported) way?  Is this just not a good idea for some reason I'm not
>thinking of?  Any comments appreciated (well friendly ones anyway...  ;-) )!
>
>Thanks!
>-Arian
>
>Arian Kulp
>Java Developer
>AEGON Financial Partners
>akulp@aegonusa.com
>319.298.4117
>
>
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>


-- 
--
* Joe Germuska    { joe@germuska.com }
"It's pitiful, sometimes, if they've got it bad. Their eyes get 
glazed, they go white, their hands tremble.... As I watch them I 
often feel that a dope peddler is a gentleman compared with the man 
who sells records."
	--Sam Goody, 1956
tune in posse radio: <http://www.live365.com/stations/289268>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>