MVP For GWT 系列资料转载一:Quick note on using gwt-presenter’s ActionException

源文转自: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.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值