RE: Global Forwards and Tiles

2003-08-15 Thread Hue Holleran
Hi David,

I think the fundamental problem here is that global-forwards are not
available to be called from outside the server. If one considers the URL one
might use to call global-forwards, e.g.:

http://myHost/myApp/myForward

... then this will not be passed-to struts - and will instead look for a
servlet mapping matching the "myForward" pattern - and probably won't find
one.

If you look at the result of a global-forwards/forward generated by say:

Forward Me!

... e.g. where the following configures the forward in struts-config to
forward to the "myAction" action:

...

...

...

...

... then it will likely be of the form when rendered to HTML:

Forward Me!

... then this _will_ go through the struts servlet and be correctly mapped
to an action.

If you wanted a way of configuring a method of calling any tiles def from a
jsp then one option would be to have a generic action than can fwd to the
tiles def, e.g. define a bean and action in struts-config:

...

...



...

...

...

...



...

...

The action code would look like this (ok, error handling could be a bit
tighter(!)) but this gives the idea:

package tld.domain.actions;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletContext;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;

import org.apache.struts.action.DynaActionForm;

public final class TilesDefFwdAction extends Action {

public ActionForward execute(ActionMapping mapping,
 ActionForm form,
 HttpServletRequest request,
 HttpServletResponse response)
 throws Exception {
String tilesDef = "";
// Get our parameter(s) from the form
DynaActionForm dynaForm = (DynaActionForm) form;
try {
tilesDef = dynaForm.get("tilesDef").toString();
} catch (Exception ex) {
// Something went wrong - send to error page
return ( mapping.findForward("tiles-def-not-passed") );
}
// Forward to tiles def
return ( new ActionForward(tilesDef,false) );
}
}

This would then allow a URL of the following format, e.g:

http://www.domain.tld/myApp/do/tilesDefFwd?tilesDef=myDef

... that would then forward to the tiles def "myDef", e.g.

Forward Me To Tiles
Def!

Alternatively, there may already be a mechanism to do this natively in
struts - but have attached the above code as this is what I wrote when I was
getting to grips with forwards/actions/tiles-defs etc - and hopefully it
will be of some help!

Hue.

> -Original Message-
> From: David Holtzhouser [mailto:[EMAIL PROTECTED]
> Sent: 15 August 2003 14:57
> To: [EMAIL PROTECTED]
> Subject: Global Forwards and Tiles
>
>
> I've attached a discussion with a fellow developer
> regarding Global Forwards and Tiles.  The tiles-defs
> are in xml if that makes any difference.
>
>  *
>  Here's the delima. I can configure a Global Forward
> that maps to my tiles definition. If I refer to this
> global forward from an Action then it finds my tile
> def. But, If I call this global forward from a jsp,
> then it craps out. But normally you can call a global
> forward from a JSP and it will work fine, as long as
> you are not using tiles defs. So, it seems like if I
> want to get from one JSP to another tiles def, then I
> have to go through a Action, which could be a
> ForwardAction. My Actions can use my global forwards,
> but my pages cannot. It's kind of weird, but I at
> least I understand what I can and can't do now.
>   *
>
> So are thought is that Global ActionForwards defined
> in the  section of the
> struts-config.xml really don't go through the
> ActionServlet at all, or somehow skip allowing the
> ActionServlet's, RequestProcessor delegate:
>
>  processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>
>
> to handle it.
>
> Can anyone provide clarification on this?
>
> Thanks
>
>
>
> __
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (

RE: Global Forwards and Tiles

2003-08-15 Thread Witbeck, Shane
My solution to this problem is not to define any global forwards and route
everything through an Action. If you are forwarding to a simple JSP defined
by a tile then define an action-mapping using a ForwardAction. 

HTH,

Shane

-Original Message-
From: David Holtzhouser [mailto:[EMAIL PROTECTED]
Sent: Friday, August 15, 2003 9:57 AM
To: [EMAIL PROTECTED]
Subject: Global Forwards and Tiles


I've attached a discussion with a fellow developer
regarding Global Forwards and Tiles.  The tiles-defs
are in xml if that makes any difference.

 *
 Here's the delima. I can configure a Global Forward
that maps to my tiles definition. If I refer to this
global forward from an Action then it finds my tile
def. But, If I call this global forward from a jsp,
then it craps out. But normally you can call a global
forward from a JSP and it will work fine, as long as
you are not using tiles defs. So, it seems like if I
want to get from one JSP to another tiles def, then I
have to go through a Action, which could be a
ForwardAction. My Actions can use my global forwards,
but my pages cannot. It's kind of weird, but I at
least I understand what I can and can't do now.
  *

So are thought is that Global ActionForwards defined
in the  section of the
struts-config.xml really don't go through the
ActionServlet at all, or somehow skip allowing the
ActionServlet's, RequestProcessor delegate:



to handle it.  

Can anyone provide clarification on this?

Thanks



__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

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