[seam-issues] [JBoss JIRA] Commented: (JBSEAM-3769) org.jboss.seam.ui.facelet.RendererRequest replaces HttpServletXXX with MockHttpServletXXX

Tihomir Surdilovic (JIRA) jira-events at lists.jboss.org
Mon Mar 1 15:10:10 EST 2010


    [ https://jira.jboss.org/jira/browse/JBSEAM-3769?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12517395#action_12517395 ] 

Tihomir Surdilovic commented on JBSEAM-3769:
--------------------------------------------

The method added to MockHttpServletRequest:

public MockHttpServletRequest(HttpSession session, ExternalContext externalContext) 

was never being called. The IllegalStateException was being thrown due to the cleanup code. This is similar to what Stan had to deal with in JSFUNIT-173.
After reading the support case (https://enterprise.redhat.com/issue-tracker/?module=issues&action=view&tid=313697&gid=1354) the requested feature is for the original request attributes to be present in the created MockHttpServletRequest. To accomplish this only one change is needed in RendererRequest:

private void init()
   {
      if (FacesContext.getCurrentInstance() != null) {
         request = new MockHttpServletRequest(HttpSessionManager.instance(), FacesContext.getCurrentInstance().getExternalContext());  
      } else {
         request = new MockHttpServletRequest(HttpSessionManager.instance());
      }
      response = new MockHttpServletResponse();
.......

with this the mail example runs without throwing the exception after mail is sent and the attributes get copied over correctly. 

Marek, please let me know when this is safe to check in.

> org.jboss.seam.ui.facelet.RendererRequest replaces HttpServletXXX with MockHttpServletXXX
> -----------------------------------------------------------------------------------------
>
>                 Key: JBSEAM-3769
>                 URL: https://jira.jboss.org/jira/browse/JBSEAM-3769
>             Project: Seam
>          Issue Type: Bug
>          Components: JSF Integration
>    Affects Versions: 2.1.1.CR1, 2.2.0.CR1
>         Environment: Mac OS X 10.5.5
> JBoss AS 4.2.3.GA
> JBoss Seam 2.1.1.CR1
> Java 6
>            Reporter: Kenneth Christensen
>            Assignee: Samuel Mendenhall
>             Fix For: 2.2.1.CR2
>
>         Attachments: MockHttpServletRequest.diff, MockHttpServletRequest.diff, RendererRequest.diff, RendererRequest.diff
>
>
> Seam 2.0.3:
>       private void init()
>       {
>          // Make sure we are using the correct ClassLoader
>          originalClassLoader = Thread.currentThread().getContextClassLoader();
>          Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
>          // If a FacesContext isn't available, set one up
>          if (FacesContext.getCurrentInstance() == null)
>          {
>             MockFacesContext mockFacesContext = new MockFacesContext(new MockExternalContext(new MockServletContext()))
>                      .setCurrent();
>             mockFacesContext.createViewRoot();
>          }
>          FacesContext facesContext = FacesContext.getCurrentInstance();
>          // Wrap the ResponseWriter
>          originalResponseWriter = facesContext.getResponseWriter();
>          facesContext.setResponseWriter(facesContext.getRenderKit().createResponseWriter(writer,
>                   null, null));
>          // Create a new UIViewRoot
>          originalViewRoot = facesContext.getViewRoot();
>          UIViewRoot viewRoot = new UIViewRoot();
>          viewRoot.setRenderKitId(facesContext.getApplication().getViewHandler().calculateRenderKitId(facesContext));
>          viewRoot.setViewId(viewId);
>          viewRoot.setLocale(originalViewRoot.getLocale());
>          facesContext.setViewRoot(viewRoot);
>       }
> Seam 2.1.1.CR1:
>    private void init()
>    {
>       request = new MockHttpServletRequest(HttpSessionManager.instance());
>       response = new MockHttpServletResponse();
>       
>       // Generate the FacesContext from the JSF FacesContextFactory
>       originalFacesContext = FacesContext.getCurrentInstance();
>       facesContext = RendererFacesContextFactory.instance().getFacesContext(request, response);
>       DelegatingFacesContext.setCurrentInstance(facesContext);
>       
>       // Create the viewRoot
>       UIViewRoot newRoot = facesContext.getApplication().getViewHandler().createView(facesContext, viewId);
>       facesContext.setViewRoot(newRoot);
>       
>       // Set the responseWriter to write to a buffer
>       writer = new StringWriter();
>       facesContext.setResponseWriter(facesContext.getRenderKit().createResponseWriter(writer,
>       null, null));
>    }
> As you can see, Seam 2.1.1.CR1 never checks for the original FacesContext, but creates a new FacesContext which includes the MockHttpServletXXX.
> It's a problem for the application I'm developing, because I need the external context (HttpServletResponse) when I'm using the renderer.render("/abc/xyz.xhtml").
> It works fine with Seam 2.0.3, but not with Seam 2.1.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the seam-issues mailing list