Hi i need some guidance or pointer of how to do a wrapper of a javascript library.
I make a simple javascript “myTest.js” with a function:
function myFunction(num)
{
if(num==1){
return "Hello World1!";
}else{
return "bye World2!";
}
}
And the i called in my simple HTML:
<html>
<head>
<script type="text/javascript" SRC="myLib.js">
</script>
<title>Tutorial: HelloWorld</title>
</head>
<body>
<h1>Example HTML</h1>
<input type="button" value="button" onclick="alert(myFunction(1))">
</body>
</html>
Obviously this example is very easy to do in GWT.
This is only to i learn how do i do a gwt-wrapper of the javascript file to be able to call the function in GWT.
Thanks
ok, i need a more powerfull example if i have an js file with this function:
function MyObject() {
// properties in config
this.displayname = 'First Last';
this.username = '1060';
this.domain = '12.18.34.234';
this.authname = '1060';
this.password = '1060';
this.transport = 'w34s';
}
and in html is script part i made this call
var myObj = new MyObject();
how do i make this in GWT??
do i have to create the class MyObject?
with the fields presented in javascript?
If you want to call native javascript in GWT you can define a native method in your GWT class like this:
When you call the method test(“foo”) from GWT it will call the native js function myFunction(“foo”);