Re: Dealing with Struts Forwards

Scott Farquhar <[email protected]> Thu, 28 Jul 2005 16:44:35 +1000
Newsgroups gmane.comp.web.sitemesh.general,gmane.comp.lang.pnuts.user
Message-ID <[email protected]>
Sonik,

Ketan wrote:
> I'm using struts on Tomcat 4.1.x (2.3 container) and trying to use different decorators depending on the url that is forwarded after an action completes.  From the posts I have been reading in this forum, forwards can only be decorated if you are using a 2.4 container i.e Tomcat 5.x.  As this is not possible for me is there any other work around besides using the calling url to perform the mapping to a decorator?  I cannot use redirect=true as there are request attributes that are required in the results page.  Also 
> 
> I was thinking whether it is possible to use a ConfigDecoratorMapper for most situations and for those where I need a different decorator specifying it in the actual page as a PageDecoratorMapper.  If this is possible are there any examples of how to do this at all.

The behaviour of forwards was not clarified until the 2.4 spec.  Some 
containers (Orion) allowed decorators to be applied around every 
forward, while other containers only allowed them at the top level.

However, you could probably write a DecoratorMapper similar to the 
ConfigDecoratorMapper, which instead of using the 
request.getRequestURI() uses the request attribute 
"javax.servlet.include.request...." (sorry - offline - can't look it up).

The request attribute contains the URI of the forwarded or included 
page, and you could use that instead.

Let me know how you go.

Cheers,
Scott


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]