• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to do exception handling in JSF

 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, before we answer your question, which one do you think is the best approach ?
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dhananjay,

In the second approach do we have to use "action" attribute?
 
Dhananjay Inamdar
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 27807
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rita!

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

It's better to start your own thread.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic