May be I understand why SwicthAction is needed. 

If I want to forward from an Action in module A to a JSP in module B, I can
set the contextRelative to true.

<global-forwards>
    <forward name="toModuleB"
       contextRelative="true"
       path="/moduleB/index.jsp"
       redirect="true"/>
    ...
</global-forwards>

However when I get to JSP in moduleB, I am still really in module A (Module
A is the current module on the request). All URLs I build using the
<html:link> tag will prepend moduleA even though the JSP is in module B.  

Does this mean that I can never forward to a JSP in another module directly
and I should use SwitchAction as an intermediate forward. Seems like too
much work just to forward to a JSP. Also this makes contextRelative forwards
useless in most cases.


Sanjay


-----Original Message-----
From: Sharma, Sanjay (LNG-DAY) [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 30, 2003 1:18 PM
To: Struts Users Mailing List
Subject: Why do we need SwitchAction



I am wondering why SwicthAction is needed. 

The following example uses SwitchAction to switch from module test2 to
module test.

In config file of module test2.
    ...
    <action-mappings>
    <action path="/toModule"
    type="org.apache.struts.actions.SwitchAction"/>
    ...
    </action-mappings>
    ...

To forward to Action test in module test from an Action in current module
(test2), I can use
 
        return (new
ActionForward("/toModule.do?prefix=/test&page=/test.do"));

But I can accomplish the same thing by doing

        ActionForward af = new ActionForward("/test/test.do");
        af.setContextRelative(true);
        return af;

So why do we need SwitchAction

Sanjay



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to