Have you read http://struts.apache.org/userGuide/configuration.html#module_config-switching? It explains how to use contextRelative forwards in Module A to forward to pages in Module B.

If that's not what you need, you could define all of your application-global forwards in an XML external entity file and reference that in the global-forwards section of each of your module configuration files.

1) Create a file called global-forwards.xml that looks like this:

<forward name="indexHome" contextRelative="true" path="/index/index.do" redirect="true"/>
<forward name="modAHome" contextRelative="true" path="/modA/index.do" redirect="true"/>


... and so forth

2) Declare this file as an external entity in each of your module configuration files:

<!DOCTYPE struts-config PUBLIC "public-id" "systemid
[ <!ENTITY globalForwards SYSTEM "../path/to/global-forwards.xml"> ]>

3) Create a global-forwards section in each module that looks like so:
<global-forwards>
 <!-- Module-global forwards -->
 <forward name="page1" path="page1.do"/>
 <forward name="page2" path="page2.do"/>
 <!-- Pull in the contents of the globalForwards entity -->
 &globalForwards;
</globalForwards>

Peter Werno wrote:
Hello Jeff,

thanks for the hint. I had tested multiple variations of it, including
/index/index.do, but to no avail. I have checked in the Action Class that
tries to get it. It does

-----

ActionForward myForward = mapping.findForward("indexHome");
if(myForward == null)
    System.out.println("Forward is null!!!");

-----
and it returns null allways. I even tried different names
("index/indexHome", "/index/indexHome", etc.)

This Action Class is actually belonging to the "DEFAULT" part of the
webapp. Is it possible that "global" forwards are only global for the
module that they are defined in?

In that case, modules will probably be a no-go for me :/

Regards,

Peter



Peter Werno wrote:

This is how it works:

--------- struts-config.xml ----------

<struts-config>
   ...

   <global-forwards>
       <forward name="home" path="/index.jsp" redirect="false"/>
       <forward name="loginform" path="/login.jsp" redirect="false"/>
       <forward name="error500" path="/error/err500.jsp"
redirect="false"/>
       <forward name="trylogin" path="/loginAction.do"
redirect="false"/>
       <forward name="indexHome" contextRelative="true"
path="/index/index.do" redirect="true"/>
       .... more ....
   </global-forwards>
   ...
</struts-config>

--------- end ---------

this is how it does NOT work:

--------- index-config.xml ----------

<struts-config>
   ...
   <global-forwards>
       <forward name="indexHome" contextRelative="true" path="index.do"
redirect="true"/>
   </global-forwards>
   ...
</struts-config>

--------- end ---------

many thanks,

Peter

I think you're confused on the meaning of contextRelative. contextRelative means to interpret the path relative to the web application root, not the module root. So in your second example, the forward named 'indexHome' will attempt to find /index.do, not /index/index.do as the first example.

-- Jeff

---------------------------------------------------------------------
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