Hi
Use the qualified class name would disallow to extend events sharing the same
EventHandler.
On the bellow code you can handle all the AbstractSessionEvent extentions with
the single AbstractSessionEvent.Handler interface.
public abstract class AbstractSessionEvent extends Event<Handler> {
public interface Handler extends EventHandler {...}
protected static Type< Handler > TYPE = new Type< Handler >();
@Override
protected void dispatch(Handler handler){ ... }
}
public class LoginEvent extends AbstractSessionEvent{
public Event.Type< Handler > getAssociatedType() {
return TYPE;
}
}
public class LogoutEvent extends AbstractSessionEvent{
public Event.Type< Handler > getAssociatedType() {
return TYPE;
}
}
Their is probably mush more reasons. But I think this one is good enough.
Regards
--
Fabien.
http://pwt.putnami.org
Le 26 juin 2014 à 09:00, smiletolead <[email protected]> a écrit :
> Hi all,
>
> A custom event needs to have a TYPE variable to denote the type of the event.
> For example:
>
> public class LogoutEvent extends Event<LogoutEventHandler>
> {
> public static Type<LogoutEventHandler> TYPE = new
> Type<LogoutEventHandler>();
>
> @Override
> protected void dispatch(LogoutEventHandler handler)
> {
> handler.onLogout();
> }
>
> @Override
> public
> com.google.web.bindery.event.shared.Event.Type<LogoutEventHandler>
> getAssociatedType()
> {
> return TYPE;
> }
>
> }
>
>
> I am just curious about the need to have the TYPE field. Why GWT could not
> use the class name of the event(in this case LogoutEvent) to denote the type
> of the event. Only purpose I see of this type is to have it as a key in the
> map of events and their handlers. I think even the class name could have
> served as the key in this map.
>
> Thanks
> Ganesh
>
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.