我是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 CODE --------- ---------------------- 如何让简单的实现工作?我有什么遗失的吗?
我在java代码中给出了两个警告声明
Window.alert(&#34; HIII&#34);
aStaticMethd();
Window.alert(&#34; HELLOOOOOOO&#34);在alert语句之间我在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对象。