Pregunta

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]

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top