The solution I've come up with so far is to create an empty concrete class called None to use in the place of java.lang.Void. It's kind of hacky, but it works...
-Brian On Sun, Jan 25, 2009 at 1:21 PM, briankuhn <[email protected]> wrote: > I'm refactoring some GWT code that is currently using exceptions to > signal normal business logic failures from the RPC services. I'm > trying to change the code to handle these normal failures in the > AsyncCallback.onSuccess(T result). > > I wanted my result objects to: > 1. Be able signify that the call was either successful or failed. > 2. Be able to provide a localized failure message for failed calls. > 3. Not require creating a new class for every service method. (I > don't want the following): > > public interface MyService { > GetSomeStringReply getSomeString(GetSomeStringRequest request); > } > > The following design would work (even for service methods currently > returning void), but it looks like java.lang.Void isn't serializable, > so GWT won't compile this code. > > Has anyone run into this before? What should I do? Is there a better > known design? > > public interface Failure { > String getLocalizedMessage(Messages message); > } > > public interface Reply<T> { > boolean isSuccessful(); > T getResult(); > Failure getFailure(); > } > > public interface MyService { > Reply<String> getSomeString(); > Reply<Void> returnsNothing(); > } > > public interface MyServiceAsync { > void getSomeString(AsyncCallback<Reply<String>> callback) > void returnsNothing(AsyncCallback<Reply<Void>> callback); > } > > Thanks, > Brian --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
