开发者

Seam centralized exceptions

开发者 https://www.devze.com 2023-01-25 00:41 出处:网络
i\'m using seam 2.2, primefaces as view presentation layer. I would write some kind of infrastructure in order to capture all exceptions.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号