我是 GWT 的新手,我正在尝试使用 JsInterop 实现示例程序,但它不起作用。
JavaScript code:-
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link type="text/css" rel="stylesheet" href="Jsinterop.css">
<title>Web Application Starter Project</title>
<scripttype="text/javascript"language="javascript"src="jsinterop/jsinterop.nocache.js">
var foo = new com.example.jsinterop.client.MyJsType();
if (myType.aStaticMethd) {
alert("Ask me what's the meaning of life...");
}
</script>
</head>
<body>
</html>
How can I get simple implementation to work? Is there something I'm missing?
------------------------------------JAVA CODE----------------------------
Related detailed java code for above javaScript is:-
@JsType
public class MyJsType implements EntryPoint {
A sample type to be accessed from javaScript.
public MyJsType(){}
some method
public String aPublicMethod() {
return "Hello ";
}
@JsMethod
public static String aStaticMethd() {
return "method call";
}
on moduleload method
@Override
public void onModuleLoad() {
TODO Auto-generated method stub
Window.alert("HIII");
aStaticMethd();
Window.alert("HELLOOOOOOO");
}
}
------------------------------------JAVA代码------------ ------------------- 我怎样才能让简单的实现工作?有什么我想念的吗?
我在 java 代码
Window.alert("HIII");中给出了两个警告语句 静态方法();Window.alert("HELLOOOOOOO"); 在警报语句之间我在 javaScritp 中调用 API astaticMethod() :-
var foo = new com.example.jsinterop.client.MyJsType();
if (myType.aStaticMethd) {
alert("Ask me what's the meaning of life...");
}
</script>
带有警报语句但 javascript 警报语句未执行根据我的要求,我试图在 javaScript 中调用 java 对象。