myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Kočí (Commented) (JIRA) <...@myfaces.apache.org>
Subject [jira] [Commented] (MYFACES-3191) Handing exception (in exception handler) from render response phase with forward/redirect is inconsistent
Date Wed, 14 Mar 2012 16:08:40 GMT

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

Martin Kočí commented on MYFACES-3191:
--------------------------------------

forward vs. redirect

The nature of forward does not allow to perform it in render response phase:
1) view.xhtml is rendered (lifecycle.render)
2) an exception occurs
3) exception handler forwards to ErrorPage.xhtml
4) ErrorPage.xhtml is rendered

step 1) can produce some  output (html) elements and send it to client (depends on size of
server buffer). With this combination it is obtainable combination of both views in client:
output from view.xhtml and from ErrorPage.xhtml

The goal is:
1) provide reliable redirect from render response phase (works ok for HTML request, does not
work for ajax)
2) an attempt to forward in render response phase log as error (and ignore it?)
                
> Handing exception (in exception handler) from render response phase with forward/redirect
is inconsistent
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: MYFACES-3191
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3191
>             Project: MyFaces Core
>          Issue Type: Sub-task
>          Components: General
>    Affects Versions: 2.1.2-SNAPSHOT
>         Environment: myfaces trunk
>            Reporter: Martin Kočí
>
> View.xhtml snippet:
> <h:commandButton value="Submit">
>                 <f:setPropertyActionListener value="#{true}" target="#{bean.rendered}"
/>
>                 <f:ajax render="outputText" />
> </h:commandButton>
> <h:outputText rendered="#{bean.rendered}" id="outputText" value="#{bean.value}" />
> Bean.java snippet:
> public Object getValue() {
> 		throw new NullPointerException();
> }
> Custom exception handler code:
> 			if (PhaseId.RENDER_RESPONSE.equals(currentPhaseId)) {
> 				try {
> 					nav.handleNavigation(facesContext, null, "/ErrorPage.xhtml?faces-redirect=true");
> 				} finally {
> 					i.remove();
> 				}
> 			}
> Modify view and exception handler to achieve following combinations (HTML request = comment
out f:ajax, forward = remove ?faces-redirect=true)
> 1) HTML request  + forward: nothing in log, and malformed output is produced (no closing
tags for  </body> etc.)
> 2) HTML request + redirect: OK , redirect to ErrorPage.xhtml is done
> 3) AJAX request + forward: exception in log, bud no forward to ErrorPage performed
> 4) AJAX request + redirect: exception in log, malformed XML produced (<?xml and <partial-response
2x in output) , no redirect performed

--
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

       

Mime
View raw message