浏览 1110 次
该帖已经被评为隐藏帖
|
|
---|---|
作者 | 正文 |
发表时间:2010-03-07
最后修改:2010-03-07
源文转自:Quick note on using gwt-presenter’s ActionException
It seems that the best way to use gwt-presenter’s ActionException is to extend it, as exception chaining using ActionException does not appear to work. Here’s a working example:
package com.roa.common.exception; import net.customware.gwt.dispatch.shared.ActionException; public class UserNotLoggedInException extends ActionException { private String loginUrl; // Required for GWT-RPC! private UserNotLoggedInException() { super(); } public UserNotLoggedInException(String loginUrl) { super(); this.loginUrl = loginUrl; } public String getLoginUrl() { return loginUrl; } }Extending ActionException is nice because all your handler execute methods already declare it. And this way, in client code, you can use instanceof in your exception handlers without the need for getCause(), checking for null, etc.
Thanks to the Apache Hupa mail project for a similar example (InvalidSessionException) that helped me see the light on this! While you’re checking out Hupa, have a look at the HupaCallback class, too. Pretty nifty way to achieve centralized error handling on the client combined with gwt-presenter’s DisplayCallback class.
声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |