ajax - Why FullAjaxExceptionHandler does not simply perform an ExternalContext#redirect()? -


In OmniFaces, after using the correct error page, JSF calls the runtime to create and present the view The page that contains AJAX calls instead.

Why this? IMHO would it be easy to just ExternalContext # redirect () ? Are there specific reasons to do this?

We are writing based on our own ExceptionHandler FullExxexception handler and want to understand the reason behind this design.

<< Class> "post-text" itemprop = "text">

primaryA goal of FullAjaxExceptionHandler to give an exception during the execution of AJAX requests while implementing error pages similar to the exception during non-ajax requests, without worrying about the developer status, reusing error pages in both situations Should be able to.

A redirect is not a part of the normal flow during non-AJAX requests. In the web.xml the default & lt; Error-page & gt; The system does not have a redirect to display the error page, displays next. If any were redirected, all error page request attributes like javax.servlet.error.exception will be lost and presented as null . In addition, to prevent endorsors from being able to directly access (and bookmark and share), general practice has to put error pages in / WEB-INF . A redirect will need to make them publicly accessible, which indicates a major design problem (is actually a real error page?).

If you really want to make your home / page, either a custom exception handler, which explicitly calls externalcontontext # redirect () and Web.xml & lt; Error-page & gt; On the top of the HTML, or code in the error page, & lt; Meta http-equiv = "Refresh" ... & gt; Add .

In case you want to redirect to some login page when you are ViewExpiredException , then you should know that "user is not logged in" and "session / view key There is a big difference between the "expired time". For the first time, you should not catch ViewExpiredException , but use an easy one that logs the user and redirects accordingly, before applying FacesServlet goes.

See also:

  • A general authentication structure (JAS, head, spring protection, etc.)
  • < / Li>

Comments