You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Joe Germuska <Jo...@Germuska.com> on 2005/02/04 15:13:50 UTC

Re: 1.3 TilesPreProcessor should convert forward to include if action is called from definition

Now I understand better your earlier email.  I think it would be 
simpler to change
         doInclude = (tileContext != null);
to
         doInclude = (tileContext != null || 
swcontext.getResponse.isCommitted());

I'd never encountered this use case, so I didn't realize the need.

I'll make these two fixes you've suggested.

Joe


At 10:17 AM +0100 2/4/05, Wolfgang Gehner wrote:
>Hi Guys again,
>
>Previous Struts versions had a feature where a forward would be 
>converted to an include if
>the action was called from a tiles definition, as /do/testAct in:
>
>main.jsp
><tiles:insert definition="test.pg"/>
>
>test.pg is
><definition name="test.pg" 
>template="/WEB-INF/modules/test/inf/LayoutTest.jsp">
><put name="tileA" content="/WEB-INF/modules/test/inf/tileA.jsp"/>
><put name="tileB" content="/do/testAct"/>
></definition>
>
>Where testAct is a classic Action that forwards to a jsp.
>
>This used to work, but fails in 1.3 with
>"IllegalStateException: Cannot forward after response has been committed
>at 
>org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:314)
>at 
>org.apache.catalina.coreApplicationDispatcher.forward(ApplicationDispatcher.java:302)
>at 
>org.apache.struts.chain.commands.servlet.PerformForward.perform(PerformForward.java:84)
>
>Obviously a forward will not work when catalina has started 
>responding to "main.jsp" request.
>
>To get it to work, in my code I changed the following in 
>TilesPreProcessor.java line 188 ff (from nightly struts source 
>28jan05, did not find it in svn), see below.
>
>Best regards,
>
>Wolfgang
>
>// Do we do a forward (original behavior) or an include ?
>
>//Added (Wolfgang Gehner): If response is already committed,
>//we believe this action was called from from within a definition,
>//as in <definition ...><put name="mytile" content="/do/myAct" />
>//Should do an include instead of a forward.
>if (swcontext.getResponse().isCommitted())
>{
>   log.debug("response already committed, do an include instead of forward");
>   doInclude(swcontext, forwardConfig.getPath());
>   return true; //stop chain
>}
>
>//Now handle the case where an action forward to a definition,
>//as in action <forward name="Success" path="mydefinition"/>
>boolean doInclude = false;
>ComponentContext tileContext = null;
>
>// Get current tile context if any.
>...
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>For additional commands, e-mail: dev-help@struts.apache.org


-- 
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com    
"Narrow minds are weapons made for mass destruction"  -The Ex