David Chandler's Journal of Java Web and Mobile Development

  • David M. Chandler

    Web app developer since 1994 and Google Cloud Platform Instructor now residing in Colorado. Besides tech, I enjoy landscape photography and share my work at ColoradoPhoto.gallery.

  • Subscribe

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 224 other followers
  • Sleepless Nights…

    December 2009
    S M T W T F S
  • Blog Stats

    • 1,037,075 hits

Archive for December 9th, 2009

Quick note on using gwt-presenter’s ActionException

Posted by David Chandler on December 9, 2009

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()

	public UserNotLoggedInException(String loginUrl)
		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.

Posted in Google Web Toolkit, Model-View-Presenter | Leave a Comment »

%d bloggers like this: