Is there a way to create a new JavaScript object from GWT using JSNI? I can't seem to find any information in the documentation. I did manage to make it work by moving all the JS code to .html files, but that caused another unrelated problem.
Here is the Java code snippet:
private static native void createPicker() /*-{
var picker = new $wnd.google.picker.PickerBuilder()
.enableFeature(google.picker.Feature.NAV_HIDDEN)
....
However, I encountered the following error:
com.google.gwt.event.shared.UmbrellaException: Exception caught: (ReferenceError) @com.onix.sdm.client.SDM_Mailer::createPicker()([]): google is not defined
Upon checking the browser console, I found that the 'google' object is indeed defined:
> google
>Object {picker: Object}
For more information, you can refer to this link.
Below is the relevant HTML code:
<script type="text/javascript">
function loadPicker() {
gapi.load('picker');
}
</script>
<script type="text/javascript" src="https://apis.google.com/js/api.js?onload=loadPicker"></script>