One i missed to mention, this *solution* is not bound to MyFaces, it works also with the RI shipped by Sun...
:-) Cheers, > -----Original Message----- > From: Matthias Wessendorf [mailto:[EMAIL PROTECTED] > Sent: Thursday, June 24, 2004 7:50 PM > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: [Struts-Faces] wrapping a HttpServletRequest > > > Hi, i tried the faces-struts-lib with RI. > It works. > > But not with Open-Source-Implementation *MyFaces*. > i notices, that in struts-faces the servletPath is > a *.do (or that for struts). > > But it must be an faces-mapping for servlet-Path > (*.faces e.g.) > the FacesRequestProcessor know if request is for > ActionSerclet or not. > > If not, it delegates it to JSF-Impl. > Base of checking is a URI, that is configed > in <forward name="success" path="/test.faces"/> (e.g.) > > so i wrote a simple HttpServletRequestWrapper > which wrappes the uri as new ServletPath. > now everything is fine. > > like this (in FacesRequesProcessor) > <code> > FacesContextFactory fcf = (FacesContextFactory) > > FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY); > > HttpServletRequestWrapper wrapper = new > HttpServletRequestWrapper(request,uri); > > > context = fcf.getFacesContext(servlet.getServletContext(), > wrapper, > response, lifecycle); > </code> > it is not an error in myfaces-impl. > it is an bug in the RI. > > please see the email of Ted Husted (on myfaces-list) > <ted> > > On Wed, 23 Jun 2004 20:21:49 -0700, > [EMAIL PROTECTED] wrote: > > the MyFaces implementation is correct in this aspect and I > don't think > > > we should clone the bugs of the RI just because struts > relies on them. > > > I hope spec-compliant does not mean we have to have the > same bugs the > > RI has ;-)? By the way, if the RI is fixed, struts will not > work there > > > any longer, too. > > The RI and Struts-Faces were created in tandem, so it's not > surprising the same assumptions crop up in each. But, no, > specification-compliant does not mean that we should rely on > bugs in any implementation, including the RI. In fact, the > Struts tradition has been to expose bugs in implementations > so that vendors are compelled to fix them. > > If you develop any patches you would like applied, please > bring them to my attention. Once we can get 1.2.1 > out-the-door (could be this week), we will be setting up > several subprojects, including Struts-Faces, that can be > released separately. > > > So the clean solution from my point of view is to fix the issue in > > struts. For example it would be possible to wrap the > servlet request > > before the FacesContext is created. The wrapper takes the > uri of the > > view to be displayed to simulate a valid jsf servlet path > for the view > > > manager. What do you think? > > > > Oliver > > </ted> > > > and here is the simple wrapper-class: > i can apply a patch, but on that i will > do a bit better documentation of that > wrapper-class > > > Cheers, > Matthias > > /* > * Copyright 2002,2004 The Apache Software Foundation. > * > * Licensed under the Apache License, Version 2.0 (the "License"); > * you may not use this file except in compliance with the License. > * You may obtain a copy of the License at > * > * http://www.apache.org/licenses/LICENSE-2.0 > * > * Unless required by applicable law or agreed to in writing, software > * distributed under the License is distributed on an "AS IS" BASIS, > * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either > express or implied. > * See the License for the specific language governing permissions and > * limitations under the License. > */ > package org.apache.struts.faces.util; > > import java.io.BufferedReader; > import java.io.IOException; > import java.io.UnsupportedEncodingException; > import java.security.Principal; > import java.util.Enumeration; > import java.util.Locale; > import java.util.Map; > > import javax.servlet.RequestDispatcher; > import javax.servlet.ServletInputStream; > import javax.servlet.http.Cookie; > import javax.servlet.http.HttpServletRequest; > import javax.servlet.http.HttpSession; > > /** > * <p>Concrete implementation of <code>HttpServletRequest</code> that > * that wrapps the <code>ServletPath</code> with an URI, that > was detected > * by <code>ActionServlet</code> to forward to a standard > <code>FacesServlet</code>. > * > */ > public class HttpServletRequestWrapper implements HttpServletRequest { > > // ------------------------------------------------------ > Instance Variables > > protected HttpServletRequest original = null; > protected String servletPath = null; > > // ------------------------------------------------------------ > Constructors > > > /** > * <p>Construct a new <code>HttpServletRequest</code> instance > * and an URI, which is used by <code>FacesServlet</code>.</p> > * > * @param request Original default > <code>HttpServletRequest</code> > * > * @param servletPat the new ServletPath for a > <code>FacesServlet</code> > * > */ > > public HttpServletRequestWrapper(HttpServletRequest > request, String servletPath){ > this.original = request; > this.servletPath = servletPath; > } > > // ---------------------------------------------------------- > Public Methods > > > /** > * <p>Returns the new <code>ServletPath</code> needed > by a FacesServlet.</p> > * > */ > public String getServletPath() { > // TODO Auto-generated method stub > return this.servletPath; > } > > // ---------------------------------------------------------- > Delegate Methods > > > /* (non-Javadoc) > * @see java.lang.Object#equals(java.lang.Object) > */ > public boolean equals(Object arg0) { > return original.equals(arg0); > } > > ... > } > > > > > --------------------------------------------------------------------- > 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]