EventBus mechanism

66 views
Skip to first unread message

Adio

unread,
May 1, 2012, 9:01:20 AM5/1/12
to Google Web Toolkit
Hi everyone, now that i am working with GWT i am facing a problem with
the event handling mechanism the first problem was (
http://groups.google.com/group/google-web-toolkit/browse_thread/thread/17b679b499311756/8f06531e30bf0996#8f06531e30bf0996
), but when i read this article MVP II (
https://developers.google.com/web-toolkit/articles/mvp-architecture-2
) - actually i read it several times - i still don't understand when u
to use EventBus mechanism and when not ? and if i have to use when u
use EventBus Handler and HandlerManage ?.
Here is what confuses me:

public class ContactsPresenter implements Presenter,
ContactsView.Presenter<ContactDetails> {
......
public void onAddButtonClicked() {
eventBus.fireEvent(new AddContactEvent());
}

public void onDeleteButtonClicked() {
deleteSelectedContacts();
}

public void onItemClicked(ContactDetails contactDetails) {
eventBus.fireEvent(new EditContactEvent(contactDetails.getId()));
}

....
}

Why one method fires and event and the other just do some logic witch
is defined the class ?

Thank you all for your replies.

the source code of the example is here :
http://google-web-toolkit.googlecode.com/files/Tutorial-Contacts2.zip

Jambi

unread,
May 1, 2012, 7:14:16 PM5/1/12
to google-we...@googlegroups.com
Seems that the onAddButtonClicked and onItemClicked methods perform some actions that involve other Presenters/Views that listen to those kinds of events. deleteSelectedContacts is just performing local changes that don´t affect other views. If there would be a different view that is showing a (for example) contact count and this view needs to know about some changes in your contacts, you would fire an event in deleteSelectedContacts.

Adio

unread,
May 2, 2012, 2:40:10 AM5/2/12
to Google Web Toolkit
Aha, got it !

On May 2, 2:14 am, Jambi <michael.lukaszc...@googlemail.com> wrote:
> Seems that the onAddButtonClicked and onItemClicked methods perform some
> actions that involve other Presenters/Views that listen to those kinds of
> events. deleteSelectedContacts is just performing local changes that don´t
> affect other views. If there would be a different view that is showing a
> (for example) contact count and this view needs to know about some changes
> in your contacts, you would fire an event in deleteSelectedContacts.
>
> Am Dienstag, 1. Mai 2012 15:01:20 UTC+2 schrieb Adio:
>
>
>
>
>
>
>
>
>
> > Hi everyone, now that i am working with GWT i am facing a problem with
> > the event handling mechanism the first problem was (
>
> >http://groups.google.com/group/google-web-toolkit/browse_thread/threa...

Adio

unread,
May 2, 2012, 4:10:34 AM5/2/12
to Google Web Toolkit
and thank you .... !
Reply all
Reply to author
Forward
0 new messages