You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2003/06/18 22:11:03 UTC

DO NOT REPLY [Bug 20890] New: - Struts - Faces - Tiles - integration bug and fix

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20890>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20890

Struts - Faces - Tiles - integration bug and fix

           Summary: Struts - Faces - Tiles - integration bug and fix
           Product: Struts
           Version: 1.1 Beta 3
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Struts-Faces Library
        AssignedTo: struts-dev@jakarta.apache.org
        ReportedBy: nithin.mallya@tgslc.org


I am working on integrating struts-tiles-JSF using the struts-faces.jar v4
I noticed the following issue

The response ends up as committed the first time you hit a page with faces in 
it when your accessing it using struts-Tiles. That is, even if your accessing a 
page with just a image on it using Faces, when it loads you get the "Response 
has already been committed" error message. 
I had to modify the ViewHandlerImpl class as follows so that if the response 
was not committed then it would forward the request appropriately.
Please see the comment "Changed by Nithin" in the code where i had to make 
changes in the "renderView" method.

// Source File Name:   ViewHandlerImpl.java

package com.sun.faces.lifecycle;

import java.io.IOException;

import javax.faces.FacesException;
import javax.faces.context.FacesContext;
import javax.faces.lifecycle.ViewHandler;
import javax.faces.tree.Tree;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sun.faces.util.Util;

public class ViewHandlerImpl
    implements ViewHandler
{

    public ViewHandlerImpl()
    {
    }




    public void renderView(FacesContext context)throws 
IOException,FacesException
       
    {
        if(context == null)
        {
            throw new NullPointerException(Util.getExceptionMessage
("com.sun.faces.NULL_CONTEXT_ERROR"));
        } else
        {
        	
            HttpServletRequest request = (HttpServletRequest )
context.getExternalContext().getRequest();
			HttpServletResponse response = (HttpServletResponse )
context.getExternalContext().getResponse();

            RequestDispatcher requestDispatcher = null;
            Tree tree = context.getTree();
            String requestURI = context.getTree().getTreeId();

            requestDispatcher = request.getRequestDispatcher(requestURI);
            try{
// Changed by Nithin -- BEGIN

				if( !response.isCommitted() ) {
					requestDispatcher.forward(request, 
response);
				} else {
					requestDispatcher.include(request, 
response);
// Changed by Nithin -- END

				}
            } catch(ServletException se){
            	throw new FacesException(se);
            }
            return;
        }
    }
}

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org