gwtgoogle-wavegwt2

google wave: how did they make divs clickable


As we are facing GWT performance issues in a mobile app I peeked into Google Wave code since it is developed with GWT.

I thought that all the buttons there are widgets but if you look into generated HTML with firebug you see no onclick attribute set on clickable divs. I wonder how they achieve it having an element that issues click or mousedown events and seemingly neither being a widget nor injected with onclick attribute.

Being able to create such components would surely take me one step further to optimizing performance.

Thanks. ps: wasnt google going to open source client code too. Have not been able to find it.


Solution

  • The GWT documentation shows how to create handlers within a GWT Java app:

    public void anonClickHandlerExample() {
      Button b = new Button("Click Me");
      b.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
          // handle the click event
        }
      });
    }
    

    This will generate an HTML element and bind a click handler to it. However, in practice this has the same result as using document.getElementById('element').onclick() on an existing element in your page.