Say I have a Java class Course
that has some method testMethod
. How do I expose this functionality such that I can interact with it using hand-written JavaScript as follows:
someCourse.testMethod();
where someCourse
is passed directly from the Java code via a native method, like:
private native void AssociateCourse(Course course) /*-{
someCourse = course;
}-*/;
The main issue I am having in achieving this is that GWT does not provide any way for me to access the prototype of the Course
constructor. For example, the following is invalid:
private native void Expose() /*-{
$wnd.Course = @mypackage.Course;
}-*/;
because it expects it to access some field, not the whole thing.
I would like to avoid using a library like gwt exporter because I feel that having to incorporate that into my source code which handles application logic will make it difficult to separate those two aspects of my code, which will be a bad thing if the code were shared between a GWT project like this and an Android application, for example.