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 <lu...@gmail.com> on 2008/07/05 04:10:28 UTC
[myfaces core] Redirect to a JSF page when Throwable exception or error occur
Hi
I want to see what people think about a possible enhancement of error
handling feature of myfaces, thanks to a suggestion of Martin.
For this purpose, I create a issue on jira ( MYFACES-1889).
The summary of this feature is this:
One possible enhancement to the error handling feature of myfaces could be
the capability of redirect to a jsf page.
I have studied the issue in deep and the thing could be as described below:
1. Add this configuration to WEB-INF/web.xml
<context-param>
<description>
Handle exceptions with jsf redirect page.
</description>
<param-name>org.apache.myfaces.ERROR_HANDLING_REDIRECT_PAGE</param-name>
<param-value>true</param-value>
</context-param>
2. Define a navigation rule like this:
<navigation-rule>
<from-view-id>*</from-view-id>
<navigation-case>
<from-outcome>java.lang.NullPointerException</from-outcome>
<to-view-id>/nullErrorPage.jsp</to-view-id>
</navigation-case>
</navigation-rule>
Note that in from-outcome there is defined the class name of the error to be
redirected by this page.
The first test of this feature has been successful, but there are some
questions to be solved:
1. How to add error information to be displayed (maybe add as a value on the
request scope like exceptionList)
2. How to handle multiple errors, maybe the best is use a special outcome
like org.apache.myfaces.MultipleThrowable
I'll do some test this weekend and add a possible patch of this feature.
Suggestions are welcome.
regards
Leonardo Uribe
Re: [myfaces core] Redirect to a JSF page when Throwable exception or error occur
Posted by Martin Marinschek <ma...@gmail.com>.
Hi Leonardo,
- the error-handling (also making it possible to handle multiple
errors) needs to remain in MyFaces core
- the new feature with the navigation can be one of the error-handlers
that can be configured, and can surely reside in the sandbox...
@Seam: I doubt that Seam can do proper exception-handling across the
full JSF lifecycle - there is just no integration point which would
work outside of the FacesServlet. We will have to wait for JSF 2.0 to
get such an integration point.
regards,
Martin
On 7/6/08, Stephen Friedrich <my...@eekboom.com> wrote:
> I agree that this is useful, but should _not_ be in core.
>
> It's nothing new, however, the Seam framework has a nice, robust
> implementation of a very similar feature:
> http://docs.jboss.com/seam/2.1.0.A1/reference/en/html/events.html#d0e4418
>
> If you choose to copy that effort, please make sure that is does not
> interfere with Seam's (or any other framework's) error handling.
>
> Leonardo Uribe wrote:
>>
>>
>> On Sat, Jul 5, 2008 at 5:35 AM, Mario Ivankovits <mario@ops.co.at
>> <ma...@ops.co.at>> wrote:
>>
>> Hi!
>>
>> One possible enhancement to the error handling feature of
>> myfaces could be the capability of redirect to a jsf page.
>>
>> Any concrete use-case for this, or just yet another
>> "cool-we-can-make-it" thingy? ;-)
>>
>>
>> The idea could be create a custom exception hierarchy for a selected
>> app. Then use the previous idea to define how to manage each exception
>> properly.
>>
>> When you do custom apps, it is common to handle this type of exceptions
>> on the beans and take the proper actions inside it. This proposal could
>> make easier handle this scenarios (Think on the possible alternatives of
>> a custom action between several pages, example: a page to query some
>> data and if no data found throw DataNotFoundException, so redirect to a
>> page xxx or something like that).
>>
>> Obviously, there are other alternatives to do the same (handle errors).
>> But the only way to know which option is better is trial and error.
>>
>> This feature could be on sandbox (after all, this is the place for trial
>> and error). But I'm not very sure about this idea, maybe let it in
>> another place.
>>
>>
>>
>> Seriously, what's wrong with the error page capabilities of the
>> webapp container?
>> Instead of error-code you can have error-type. Never used, tough.
>> Probably it would be enough to learn the Faces-Servlet to unwrap the
>> real exception instead of introduce another error handling stuff.
>>
>> Even this I'd do with a Faces-Servlet wrapper, more like a general
>> purpose exception-unwrapper-servlet so that this can work with
>> Mojarra and whatever.
>>
>>
>> Ciao,
>> Mario
>>
>>
>
>
--
http://www.irian.at
Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German
Professional Support for Apache MyFaces
Re: [myfaces core] Redirect to a JSF page when Throwable exception
or error occur
Posted by Stephen Friedrich <my...@eekboom.com>.
I agree that this is useful, but should _not_ be in core.
It's nothing new, however, the Seam framework has a nice, robust
implementation of a very similar feature:
http://docs.jboss.com/seam/2.1.0.A1/reference/en/html/events.html#d0e4418
If you choose to copy that effort, please make sure that is does not
interfere with Seam's (or any other framework's) error handling.
Leonardo Uribe wrote:
>
>
> On Sat, Jul 5, 2008 at 5:35 AM, Mario Ivankovits <mario@ops.co.at
> <ma...@ops.co.at>> wrote:
>
> Hi!
>
> One possible enhancement to the error handling feature of
> myfaces could be the capability of redirect to a jsf page.
>
> Any concrete use-case for this, or just yet another
> "cool-we-can-make-it" thingy? ;-)
>
>
> The idea could be create a custom exception hierarchy for a selected
> app. Then use the previous idea to define how to manage each exception
> properly.
>
> When you do custom apps, it is common to handle this type of exceptions
> on the beans and take the proper actions inside it. This proposal could
> make easier handle this scenarios (Think on the possible alternatives of
> a custom action between several pages, example: a page to query some
> data and if no data found throw DataNotFoundException, so redirect to a
> page xxx or something like that).
>
> Obviously, there are other alternatives to do the same (handle errors).
> But the only way to know which option is better is trial and error.
>
> This feature could be on sandbox (after all, this is the place for trial
> and error). But I'm not very sure about this idea, maybe let it in
> another place.
>
>
>
> Seriously, what's wrong with the error page capabilities of the
> webapp container?
> Instead of error-code you can have error-type. Never used, tough.
> Probably it would be enough to learn the Faces-Servlet to unwrap the
> real exception instead of introduce another error handling stuff.
>
> Even this I'd do with a Faces-Servlet wrapper, more like a general
> purpose exception-unwrapper-servlet so that this can work with
> Mojarra and whatever.
>
>
> Ciao,
> Mario
>
>
Re: [myfaces core] Redirect to a JSF page when Throwable exception or error occur
Posted by Leonardo Uribe <lu...@gmail.com>.
On Sat, Jul 5, 2008 at 5:35 AM, Mario Ivankovits <ma...@ops.co.at> wrote:
> Hi!
>
>> One possible enhancement to the error handling feature of myfaces could be
>> the capability of redirect to a jsf page.
>>
> Any concrete use-case for this, or just yet another "cool-we-can-make-it"
> thingy? ;-)
>
The idea could be create a custom exception hierarchy for a selected app.
Then use the previous idea to define how to manage each exception properly.
When you do custom apps, it is common to handle this type of exceptions on
the beans and take the proper actions inside it. This proposal could make
easier handle this scenarios (Think on the possible alternatives of a custom
action between several pages, example: a page to query some data and if no
data found throw DataNotFoundException, so redirect to a page xxx or
something like that).
Obviously, there are other alternatives to do the same (handle errors). But
the only way to know which option is better is trial and error.
This feature could be on sandbox (after all, this is the place for trial and
error). But I'm not very sure about this idea, maybe let it in another
place.
>
> Seriously, what's wrong with the error page capabilities of the webapp
> container?
> Instead of error-code you can have error-type. Never used, tough.
> Probably it would be enough to learn the Faces-Servlet to unwrap the real
> exception instead of introduce another error handling stuff.
>
> Even this I'd do with a Faces-Servlet wrapper, more like a general purpose
> exception-unwrapper-servlet so that this can work with Mojarra and whatever.
>
> Ciao,
> Mario
>
>
Re: [myfaces core] Redirect to a JSF page when Throwable exception or error occur
Posted by Martin Marinschek <ma...@gmail.com>.
Hi Mario,
> I wonder why people always want a full running JSF environment for each
> and every page.
> If there is an exception it might be due to a problem in JSF itself
> which might make it impossible to show any error page at all.
> Not that you can not handle such situations (revert to default error
> handling), but it makes things complicated.
sure - but again, you are loosing the context-information of JSF if
you are on the more general error page, so you can provide less
information to the user/maintenance personnel/ etc. So I understand
the need to make this possible.
> As long as it does not break other things and is fully optional with
> non-intrusive by default I am -0 adding such a feature.
Sure - as discussed.
regards,
Martin
Re: [myfaces core] Redirect to a JSF page when Throwable exception
or error occur
Posted by Mario Ivankovits <ma...@ops.co.at>.
Hi!
> the use-case is that people want the same type of functionality they
> have in their web.xml (specifying an error-page per exception) in the
> JSF-world as well. Just doing it in the web.xml is not sufficient, as
> then the faces-context is already closed and not available anymore, so
> important context-information for the error would be missing.
>
I wonder why people always want a full running JSF environment for each
and every page.
If there is an exception it might be due to a problem in JSF itself
which might make it impossible to show any error page at all.
Not that you can not handle such situations (revert to default error
handling), but it makes things complicated.
As long as it does not break other things and is fully optional with
non-intrusive by default I am -0 adding such a feature.
Ciao,
Mario
Re: [myfaces core] Redirect to a JSF page when Throwable exception or error occur
Posted by Martin Marinschek <ma...@gmail.com>.
Hi Mario,
>> One possible enhancement to the error handling feature of myfaces
>> could be the capability of redirect to a jsf page.
> Any concrete use-case for this, or just yet another
> "cool-we-can-make-it" thingy? ;-)
the use-case is that people want the same type of functionality they
have in their web.xml (specifying an error-page per exception) in the
JSF-world as well. Just doing it in the web.xml is not sufficient, as
then the faces-context is already closed and not available anymore, so
important context-information for the error would be missing.
regards,
Martin
Re: [myfaces core] Redirect to a JSF page when Throwable exception
or error occur
Posted by Mario Ivankovits <ma...@ops.co.at>.
Hi!
> One possible enhancement to the error handling feature of myfaces
> could be the capability of redirect to a jsf page.
Any concrete use-case for this, or just yet another
"cool-we-can-make-it" thingy? ;-)
Seriously, what's wrong with the error page capabilities of the webapp
container?
Instead of error-code you can have error-type. Never used, tough.
Probably it would be enough to learn the Faces-Servlet to unwrap the
real exception instead of introduce another error handling stuff.
Even this I'd do with a Faces-Servlet wrapper, more like a general
purpose exception-unwrapper-servlet so that this can work with Mojarra
and whatever.
Ciao,
Mario