i'm using seam 2.2, primefaces as view presentation layer. I would write some kind of infrastructure in order to capture all exceptions. For example i put in a facelets following piece of code:
<p:commandButton actionListener="#{mySeamController.aMethod()}"
in MySeamController class, the above method:
public void aMethod()
{
throw new NullPointerException();
}
in the controller i write a method:
@Observer("myapp.exceptions.exception")
public void onSystemException(Exception e)
{
System.out.println("a exception was occurred");
}
i write a class to catch exceptions:
@Scope(ScopeType.APPLICATION)
@BypassInterceptors
@Install( precedence = Install.MOCK, classDependencies = "javax开发者_如何学运维.faces.context.FacesContext")
@Name("org.jboss.seam.exception.exceptions")
public class ExceptionHandler extends org.jboss.seam.exception.Exceptions{
private static final long serialVersionUID = 1L;
@Logger
Log log;
public void handle(Exception e) throws Exception
{
Events.instance().raiseEvent("myapp.exceptions.exception", e);
super.handle(e);
}
}
but i've noticed taht when i use an actionListener
<p:commandButton actionListener="#{mySeamController.aMethod()}"
instead of an action
<p:commandButton action="#{mySeamController.aMethod()}"
no exception was observed by ExceptionHandler class. Why? Can anyone help? Best regards
Create an interceptor, and you will can catch anything you need.
精彩评论