Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Empty Error Messages <h:messages/>  RSS feed

N Ha
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I want to handle unchecked exceptions in my application
I have defined a new ActionListener
public class MyActionListener extends ActionListenerImpl implements
ActionListener {

public void processAction(ActionEvent event) {
try {
} catch (Exception exception) {
FacesContext facesContext = FacesContext.getCurrentInstance();
Application application = facesContext.getApplication();
NavigationHandler navigationHandler = application.getNavigationHandler();

and added this ActionListener in the Faces config xml
<redirect />

and for a specific action I'm adding a new error message and throwing Exception
In the "MyActionListener" when I debug I can see the FacesContext.getCurrentInstance().getMessageList() has my message I added, but when the JSF "exception.xhtml" is displayed the error messages are empty
<h:messages/> presents empty list

Any help?
Tim Holloway
Posts: 18531
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's doing things the hard way.

ActionListeners are not applied globally, they must be applied explicitly for each action. And, for the record, there are very, very few cases these days when you should use ActionListeners at all. A simple Action is sufficient.

A better way to intercept and handle errors is to use the generic error handler facilities that you define in web.xml.

But the best way to handle errors is to make the action processors catch, analyze, and report them. They know more about what's going on and can therefore handle things more intelligently.

If you're experiencing a lot of unexpected random exceptions exploding out from your app, then it's time to re-examine your app for quality anyway.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!