Hi,
We're trying to integrate an existing 3rd party JQuery application into SmartGWT. We have successfully been able to do by creating a GWT (not SmartGWT) wrapper using a GWT widget.
However, we cannot seem to get this to work if we use a native SmartGWT Canvas object as the wrapper. Specifically, the 1st attached code works fine (since we're extending a GWT Widget); but the second one (in which we try to extend SmartGWT Canvas) does not work. (There are no errors, but nothing gets displayed either.) I'm almost certain that SmartGWT would support integrating with 3rd party JQuery applications, so we're wondering what simple thing we're doing wrong....
The code that *does* work (because we're extending a GWT Widget).
The code that does NOT work (ie nothing gets displayed) is below. We're extending here a SmartGWT Canvas object. (We noticed that in SmartGWT Canvas objects, the "OnLoad" doesn't seem to get called; so we tried to use the "OnDraw", but though it does get called, it just didn't display the actual 3rd party JQuery results.)
Additional info:
We tried
Also, the code that calls this object is very simple and is shown here just for completeness. We don't think it's relevant to the discussion though:
Additional infracstructure details are below:
==================================================
OS: Windows XP Pro
IDE: MyEclipse 9.0 with Google Plugin for Eclipse (2.4.2)
SmartGWT EE 3.0 (Release of November 22, 2011, ie latest)
Browwer: Mozilla Firefox 4.0.1
GWT SDK: 2.3
Sun JDK 1.6.0_27
We're trying to integrate an existing 3rd party JQuery application into SmartGWT. We have successfully been able to do by creating a GWT (not SmartGWT) wrapper using a GWT widget.
However, we cannot seem to get this to work if we use a native SmartGWT Canvas object as the wrapper. Specifically, the 1st attached code works fine (since we're extending a GWT Widget); but the second one (in which we try to extend SmartGWT Canvas) does not work. (There are no errors, but nothing gets displayed either.) I'm almost certain that SmartGWT would support integrating with 3rd party JQuery applications, so we're wondering what simple thing we're doing wrong....
The code that *does* work (because we're extending a GWT Widget).
Code:
package com.smartgwt.sample.client; import java.util.Date; import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.Widget; import com.smartgwt.client.widgets.Canvas; /** * @author gsaxena * */ public class SpectraViewer extends Widget { int count=0; public SpectraViewer(String id) { super(); Element divEle = DOM.createDiv(); setElement(divEle); divEle.setId(id); } @Override protected void onLoad() { System.out.println("Calling on load"); createSpectraViewer(this, getElement().getId()); super.onLoad(); } private native void createSpectraViewer(SpectraViewer x, String id) /*-{ $wnd.$("#" + id).specview({sequence: "FDSFGDLSSASAIMGNPK", scanNum: 2441, charge: 2, precursorMz: 1012.1, fileName:'sh_1617_JX_070209p_KO410_run1', //staticMods: staticMods, variableMods: [], ntermMod: 164.07, //ctermMod: ctermMod, peaks: [[283.751526,6.493506],[287.601379,11.096813],[295.031097,2.801403],[305.472137,2.626226],[307.404083,3.930447],[308.360321,9.893921],[310.225128,3.961838],[311.703918,3.872004]] }); }-*/; }
Code:
/** * */ package com.smartgwt.sample.client; import java.util.Date; import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.Widget; import com.smartgwt.client.widgets.Canvas; /** * @author gsaxena * */ public class SmartGWTSpectraViewer extends Canvas { int count=0; public SmartGWTSpectraViewer(String id) { super(); setWidth("80%"); setHeight("80%"); // setBackgroundColor("black"); setBorder("red"); System.out.println("The element is " + getElement()); System.out.println("THe id is " + getID()); // Element divEle = DOM.createDiv(); // setElement(divEle); // divEle.setId(id); // System.out.println("The element is now " + getElement()); // System.out.println("THe id is now " + getID()); } @Override protected void onLoad() { System.out.println("Calling on load"); createSpectraViewer(this, getElement().getId()); super.onLoad(); } @Override protected void onDraw() { System.out.println("Calling on draw with count of " + count); super.onDraw(); if (count==1) createSpectraViewer(this, getElement().getId()); count++; } private native void createSpectraViewer(SmartGWTSpectraViewer x, String id) /*-{ $wnd.$("#" + id).specview({sequence: "FDSFGDLSSASAIMGNPK", scanNum: 2441, charge: 2, precursorMz: 1012.1, fileName:'sh_1617_JX_070209p_KO410_run1', //staticMods: staticMods, variableMods: [], ntermMod: 164.07, //ctermMod: ctermMod, peaks: [[283.751526,6.493506],[287.601379,11.096813],[295.031097,2.801403],[305.472137,2.626226],[307.404083,3.930447],[308.360321,9.893921],[310.225128,3.961838],[311.703918,3.872004]] }); }-*/; }
We tried
Also, the code that calls this object is very simple and is shown here just for completeness. We don't think it's relevant to the discussion though:
Code:
... final VLayout vlRoot = new VLayout(); ... <stuff deleted that refers to formating vlRoot> SpectraViewer x = new SpectraViewer("gs_test1"); vlRoot.addMember(x); ... <stuff deleted> vlRoot.draw(); ...
==================================================
OS: Windows XP Pro
IDE: MyEclipse 9.0 with Google Plugin for Eclipse (2.4.2)
SmartGWT EE 3.0 (Release of November 22, 2011, ie latest)
Browwer: Mozilla Firefox 4.0.1
GWT SDK: 2.3
Sun JDK 1.6.0_27
Comment