0

I am self learning GWT and GWTP. I am trying to set up my logging service and I want my currentUser object to be retrieved from the server before any Presenter that depends on it is revealed.

However, I have run into an issue which I think has to do with the fact that I don't understand why, on the gwtp-sample-tab example, the class CurrentUser implements HasHandlers!.

Can somebody explain it to me? Edit for a more precise question: what I would like to know is why, on the context of the sample, CurrentUser needs to implement HasHandlers. What functionality does that satisfy in the application?

Thanks a lot, Manu

PS. I am new to StackOverflow so if you think something is wrong with my question, please let me know.

manubot
  • 290
  • 2
  • 19

1 Answers1

0

Because public class CurrentUser implements HasHandlers

because to implement the method

@Override
    public void fireEvent(GwtEvent<?> event) {
        eventBus.fireEvent(event);
    }

Which

Fires the given event to the handlers listening to the event's type.

So When a new User object creates this event register and fires at Gatekeeper(eventBus).

Suresh Atta
  • 120,458
  • 37
  • 198
  • 307
  • I know what the interface does. What I do not understand is why, in the context of the sample, CurrentUser needs to implement that interface. It seems that it is not used anywhere since [AdminAreaPresenter](https://github.com/ArcBees/GWTP-Samples/tree/master/gwtp-samples/gwtp-sample-tab/src/main/java/com/gwtplatform/samples/tab/client/application/adminarea) uses a Gatekeeper and the [Gatekeeper](https://github.com/ArcBees/GWTP-Samples/blob/master/gwtp-samples/gwtp-sample-tab/src/main/java/com/gwtplatform/samples/tab/client/security/IsAdminGatekeeper.java) access the CurrentUser object directly – manubot Oct 02 '13 at 16:18
  • It makes sense. However I still don't see how GateKeeper listens to that particular event, there does not seem to be any handler registered for it. Is that due to some magic behind the curtains? – manubot Oct 03 '13 at 10:20
  • Haven't looked through full code, yes there must be something to recieve the event and handle it. – Suresh Atta Oct 03 '13 at 10:29
  • There is nothing on the sample code. Unless Gatekeeper has some magic to register handlers based on its attributes class name I think the event is not listened anywhere. Anyways thanks for the clarifications – manubot Oct 03 '13 at 21:35