aspose file tools*
The moose likes JSF and the fly likes How to do exception handling in JSF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "How to do exception handling in JSF" Watch "How to do exception handling in JSF" New topic
Author

How to do exception handling in JSF

Dhananjay Inamdar
Ranch Hand

Joined: Jan 27, 2003
Posts: 130
Hello All,

I am working on JSF, Spring, IBatis based application.

I am looking for better of doing exception handling.

I have 2 approaches to do exception handling

1) First approach
===================
All DAO methods are throwing SqlException.
All business logic methods, are catching these SqlException and converting them to Application exception.
All beans are catching these Application Exception and adding one message in a global ArrayList.
JSF page, will show all value from ArrayList.

2) Second Appproach
====================
All DAO methods are throwing SqlException.
All business logic methods, are catching these SqlException and converting them to Application exception.
All beans are catching these Application Exception and adding meesage in FacesContext and returning FAILURE as a return value.
NavigationHandler gets this FAILURE value and redirects to the error page, which will display all messages from FacesContext

First do you see any problem in any of the approach mentioned above?
If yes then please let me know the problem and solution.

If not then please do let me know is there any other approach possible to do exception handling in more better way.
g madhava
Ranch Hand

Joined: Sep 14, 2001
Posts: 85
Well, before we answer your question, which one do you think is the best approach ?
sateesh kan
Greenhorn

Joined: Jul 27, 2006
Posts: 1
Hi Dhananjay,

In the second approach do we have to use "action" attribute?
Dhananjay Inamdar
Ranch Hand

Joined: Jan 27, 2003
Posts: 130
Hi Sateesh,

Finally we used one another approach for exception handling in our application.

But to answer your question, I don't see the necessicity for using 'action' in second approach.

Our final approach is:

1) We are using ORM layer integrated with Spring.
2) Spring is throwing DataAccessException, which is inherited from RunTimeException
3) So now our ORM methods no need to add any exception in throws clause
4) In Service/ business layer methods, who are intereacting with ORM layer, they depends on the scenario catching the exception either they are also not doing anything on exception
5) We have configured RunTimeError in WEB.XML and soowing one error page, with all infomration about the error.

Please let me know if you want clarification on this new approach.


Regards,
Dhananjay
Rita Saluja
Greenhorn

Joined: Oct 20, 2012
Posts: 1
Hi,

Can you please tell how to implement ORM layer using spring to do exception handling.

I have DAO layer in my JSF project and want to do exception handling.

Regards
Rita
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16065
    
  21

Hi Rita!

Welcome to the JavaRanch, but http://www.coderanch.com/how-to/java/DontWakeTheZombies

It's better to start your own thread.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to do exception handling in JSF