JDojo_and_Its_Usage

Download Report

Transcript JDojo_and_Its_Usage

JDojo and Its Usage
Te-Hsin Shih
04/30/2013
Dojo
• Dojo Toolkit is an open source JavaScript library
designed to ease the rapid development of
cross-platform, JavaScript/Ajax-based
applications and web sites.
• DoJo example
<script type="text/javascript">
// Load Dojo's code relating to the Button widget
dojo.require("dijit.form.Button");
</script>
<button data-dojo-type="dijit.form.Button" id="helloButton">Hello
World!</button>
JDojo
• JDojo is a toolkit that allows the developer
to use Java language to control Dojo
widgets.
• JDojo toolkit translates the Java code into
Java scripts.
• JDojo group has been quite since 2010.
Don’t know what is its future.
JDojo Example
•
WebEditor.java
public class WebEditor extends _Widget implements _Templated {
public void postCreate() {
CreateEclipseEditorParms parms = new CreateEclipseEditorParms();
parms.parent = this;
editor = utilNative.createEclipseEditor(parms);
editor.setContents("Hellow World!!");
}
}
•
WebEditor.js
dojo.declare("com.ibm.team.scm.web.ui.internal.widgets.dojoWebEditor.WebEditor", [ _Widget,
_Templated], {
postCreate: function() {
var parms= {};
parms.parent= this;
this.editor= utilNative.createEclipseEditor(parms);
this.editor.setContents("Hellow World!!");
}
});
})();
JDojo Special Syntaxes
• The “native” keyword – the native keyword in JDojo
means the implementation of the method is in the
JavaScript file.
public class Editor extends DojoObject {
public Editor(Object params) {
}
public void onInputChange(String title, String message,
String contents, boolean contentsSaved) {
...
}
public native void setContents(String contents);
}
JDojo Special Syntaxes
• @Stub annotation – it means do not generate
JavaScript file from this class.
@Stub
public class utilNative {
public static Editor createEclipseEditor
(CreateEclipseEditorParms parms)
{
return null;
}
}
References
• Install JDojo toolkits to eclipse client –
http://jazzweb.beaverton.ibm.com/foundati
on/tools/devtools-updatesite
• https://jazz.net/wiki/bin/view/Main/JDojo
Discussions
• Limitations on Java features that can be
used in JDoJo classes.