• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to do exception handling in JSF

 
Dhananjay Inamdar
Ranch Hand
Posts: 130
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 85
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, before we answer your question, which one do you think is the best approach ?
 
sateesh kan
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dhananjay,

In the second approach do we have to use "action" attribute?
 
Dhananjay Inamdar
Ranch Hand
Posts: 130
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 17616
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rita!

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

It's better to start your own thread.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic