Thanks,
Javid
Scott
Java Native code:
private native JavaScriptObject getIP() /-* {
return $wnd.ip_address
} -*/;
System.out.println(getIP());
I tried both JavaScriptObject and String return type but I get
undefined exception. It would be very helpful if you could suggest me
some quick fix as my entire application depends on this, else I have to
downgrade to gwt-1.0.21
Thanks,
Javid
Hello.html:
<html>
<head>
<script language="Javascript">
var ip_address = "10.0.0.1"
</script>
<meta name='gwt:module' content='com.google.gwt.sample.hello.Hello'>
<title>Hello</title>
</head>
<body bgcolor="white">
<script language="javascript" src="gwt.js"></script>
</body>
</html>
Hello.java:
package com.google.gwt.sample.hello.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Window;
public class Hello implements EntryPoint {
public void onModuleLoad() {
Window.alert(getIP().toString());
}
private native String getIP() /*-{
return $wnd.ip_address
}-*/;
}
Trying to return JavaScriptObject does not work, but returning a String
does work for me. Any chance you're serving up a different html file
than the one you think? I might try putting an alert() into the block
that sets up the ip_address variable.
HTH,
Scott
Javid