Everyone has a story to tell. We use these stories as a way to communicate, populating social networks, and sharing information which makes the challenge of good storytelling, important. VisualFox takes on this challenge by exploring and developing new solutions for telling your story. We join you in a new era where customers are more than customers but part of the brand, where customers expect an authentic experience anytime, everywhere, and all the time. Welcome to the new web, a web about conversation, shared experience, and storytelling.

GWT and the odd of attaching a listener to an existing DOM element

Assuming that you want to add a listener to an existing DOM element. And that you are ready to deal with potential leaking memory issue...

The new overlay way:

        Event.setEventListener(element, new EventListener() {
            @Override
            public void onBrowserEvent(Event event) {
                toggle();
            }
        });
        Event.sinkEvents(main, Event.ONCLICK);

The old way, using DOM static method:

        com.google.gwt.user.client.Element e = (com.google.gwt.user.client.Element)element;
        DOM.setEventListener(e, new EventListener() {
            @Override
            public void onBrowserEvent(Event event) {
                toggle();
            }
        });
        DOM.sinkEvents(e, Event.ONCLICK);