forgot one more interface for invoke the service

public interface GwtActionService extends RemoteService {
    <T extends Response> T execute(Action<T> action);
}

On Sep 21, 11:22 pm, Mike Wyszinski <[email protected]> wrote:
> wondering why this results in a serialization exception(running it in
> debugger-> com.google.gwt.dev.GWTShell)
> code snippets below....
>
>  I really like just needing to deal with the onSucceded() in my
> presenter code
> and leaving the  onfailure,lookup & invocation code in the action.
> This way i can easily re-use the AddEmail
> and just specialize the onSuceeded() code to update whichever display
> i happen to be working on.
>
> should this approach work?
>
> //=========================================================
> // Command pattern with some centrallized error handling
> //=========================================================
> public interface Response extends IsSerializable {}
> public interface Action<T extends Response> extends IsSerializable {}
>
> public abstract class BaseAction<T extends Response> implements
> Action<T>,AsyncCallback<T> {
>         public abstract void invoke();
>         public abstract void onSucceded(T value);
>
>         @Override
>         public void onFailure(Throwable error) {
>                 //based onExceptiontype do something(irrelevant here)
>         }
>         @Override
>         public void onSuccess(T value) {
>                 try {
>                         onSucceded(value);
>                 } catch (RuntimeException error) {
>                         onFailure(error);
>                 }
>         }
>
> }
>
> public class  AddEmailAction extends BaseAction<AddEmailResponse> {
>     private static final long serialVersionUID = 1L;
>     protected String email;
>     public AddEmailAction() {
>     }
>     public AddEmailAction(String email) {
>         this.email = email;
>     }
>
>         @Override
>         public void invoke() {
>                //note: i initialize the rpc service in the entrypoint class
>               EntryPoint.RPCSERVICE.execute(this, this);
>         }
>
>         public String getEmail() {
>                 return email;
>         }
>
>         public void setEmail(String email) {
>                 this.email = email;
>         }
>
> }
>
> //============================================
> //in the presentation tier, I try to invoke it
> //============================================
> class XYZPresenter{
>      ....
>         private void handleAddEmail(final String email){
>                 new AddEmailAction(email){
>                         @Override
>                         public void onSucceded(AddEmailResponse value) {
>                                 display.addEmail(email);
>                         }
>                 }.invoke(); <-ends up triggering -
>
> >com.google.gwt.user.client.rpc.SerializationException
>         }
> }

-- 
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.

Reply via email to