You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org> on 2012/06/04 11:31:23 UTC

[jira] [Commented] (MYFACES-3557) ViewNotFoundException using Custom Exception Handler after ViewExpiredException when using implicit navigation and prefix mapping.

    [ https://issues.apache.org/jira/browse/MYFACES-3557?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13288448#comment-13288448 ] 

Leonardo Uribe commented on MYFACES-3557:
-----------------------------------------

I have attached an alternate patch for this issue. It just adds a NavigationHandlerSupport that internally delegates to DefaultRestoreViewSupport.

I have also added some additional junit tests and rewrite some explanations. I think with the changes, the modification has sense. If no objections I'll commit the suggested solution soon.
                
> ViewNotFoundException using Custom Exception Handler after ViewExpiredException when using implicit navigation and prefix mapping.
> ----------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: MYFACES-3557
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3557
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-314
>    Affects Versions: 2.0.13
>         Environment: WebSphere Application Server  8.0 using MyFaces 2.0.13
>            Reporter: Paul Nicolucci
>         Attachments: MYFACES-3557-2.patch, NavigationHandlerImpl.patch, NavigationHandlerImplTest.patch
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> I have an application which was posted in MyFaces-3530 (ViewExpiredException.war) which uses a custom ExceptionHandler to deal with a ViewExpiredException.  Everything looks to be working as expected with this when I'm using a Faces Servlet Mapping such
> as the following (suffix mapping):
> 	<servlet-mapping>
>     		<servlet-name>Faces Servlet</servlet-name>
>    		<url-pattern>*.jsf</url-pattern>
>  	 </servlet-mapping>
> However if I use something such as this (prefix mapping):
> 	<servlet-mapping>
> 		<servlet-name>Faces Servlet</servlet-name>
> 		<url-pattern>/f/*</url-pattern>
> 	</servlet-mapping>
> I get the following exception when doing implicit navigation in my Exception Handler such as:
> 	nav.handleNavigation(fc, null, "viewExpired");  // viewExpired.xhtml exists in the web application
> Exception:
> 	Caused by: org.apache.myfaces.lifecycle.ViewNotFoundException: A view is required to execute RENDER_RESPONSE(6)
> 	at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:62)
> 	at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:239)
> 	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:191)
> According to the JSF 2.0 specification specifically Section 7.4.2:
> "If viewIdToTest does not have a “file extension”, take the file extension from the current viewId and append it
> properly to viewIdToTest."
> Since the viewId is null after the ViewExpiredException we don't have anything to grab the file extension from when using implicit navigation in this case.  
> https://issues.apache.org/jira/browse/MYFACES-3530 , deals with a similar situation where we were not adding the "/" prefix when the viewId was null. 
> The only way I could determine the extension we should be using was to call " DefaultRestoreViewSupport.calculateViewId(FacesContext context)" this uses the RequestServletPath to determine the viewId of the current view.  
> It is also worth taking note in that fact that this only looks to really matter when using prefix mapping since the algo. in 7.5.2 differs for prefix and suffix mapping.
> I've provided a patch for NavigationHandlerImpl as well as NavigationHandlerImplTest (As once the patch is applied we don't have all the information in the facesContext given the current test so we fail, however if we don't use implicit navigation in the test we can still test that we don't get any NPEs after a VEE )
> If everyone can take a look at the patch and let me know what you think that would be very helpful.  I'm willing to make changes but I've tested this and it is currently working.  I'm looking to see if I missed any cases where this would not work.  Patch contains some comments to explain what is going on and actually added an additional log statement.
> Thanks!

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira