1

I am using Chrome dev tools to step through my GWT MVP app as it renders a View using Super Dev Mode.

In the developer tools, I am stepping though the source mapped java code executing my method. I can highlight variables, right click, and "Evaluate in console" to inspect the state of my locally scoped variables.

I want to do the same things with my class members. It works in public methods. Within private methods, evaluating a class member results in a "ReferenceError: is not defined." response.

I tried annotating my class members with "this.myPanel". The response is a simple "undefined". Besides 'this' is referencing Window[0]

Stevko
  • 4,345
  • 6
  • 39
  • 66

1 Answers1

1

Try using this$static It's the object holding the members and state of instances passed as argument to functions that used to be class members but GWT compiles them to regular js functions

static members

GWT will convert static functions to just functions (not under any object in js)

public class SomeEntry implements EntryPoint {
    public static String Moo() {
        String href = Window.Location.getHref();
        return href.substring(5, 10);
    }
    public static String Moo(String x) {
        String href = Window.Location.getHref();
        return href.substring(5, 10);
    }
    public void onModuleLoad() {
        Window.alert(Moo());
        Window.alert(Moo("asd"));
    }
}

Will be compiled to:

function Moo(){
  var href_0;
  href_0 = getHref();
  return $substring_0(href_0, 5, 10);
}

function Moo_0(){
  var href_0;
  href_0 = getHref();
  return $substring_0(href_0, 5, 10);
}

So overloading which is resolved at compile time will work in JS. This has the benefit of not requiring referral using the dot operator. Each dot is a new lookup.

Community
  • 1
  • 1
tshani
  • 101
  • 1
  • 5
  • Thanks for the this$static. for referencing members from private methods. Do you know how to access static class variables? – Stevko Feb 21 '14 at 18:30
  • Static is probably converted to no namespace (in closure scope) to improve performance by not using "namespace" (dot operator). But I can't verify it. It's just a guess. – tshani Feb 21 '14 at 18:59