Canviz in GWT application

31 views
Skip to first unread message

vkrejcirik

unread,
Sep 22, 2010, 4:20:59 AM9/22/10
to canviz
Hi, I try to use canviz library in my GWT application.

1) Insert <script> elements into my html main page.

<script type="text/javascript" src="js/prototype.js"></
script>
<script type="text/javascript" src="js/path.js"></script>
<script type="text/javascript" src="js/canviz.js"></script>
<script type="text/javascript" src="js/x11colors.js"></
script>

2) In java class, I create HTML object and set:

image1.setHTML("<div id=\"image_2\"></div>");

3) Then I create native method:

public static native void getImage2(String dot) /*-{
var canviz;
canviz = new $wnd.Canviz("image_2");
canviz.load(dot);
}-*/;

When I push the button and call method getImage2, then I get this
error:

com.google.gwt.core.client.JavaScriptException: (TypeError): Cannot
set property 'innerHTML' of null
stack: TypeError: Cannot set property 'innerHTML' of null
at klass.load (http://127.0.0.1:8889/js/canviz.js:464:31)
at unknown source
at __gwt_jsInvoke (http://127.0.0.1:8889/clan/hosted.html?clan:
70:35)
at eval at <anonymous> (http://127.0.0.1:8889/clan/hosted.html?
clan:54:12)
at XMLHttpRequest.<anonymous> (unknown source)
at unknown source
at __gwt_jsInvoke (http://127.0.0.1:8889/clan/hosted.html?clan:
70:35)
at eval at <anonymous> (http://127.0.0.1:8889/clan/hosted.html?
clan:54:12)
at XMLHttpRequest.onreadystatechange (unknown source)
type: non_object_property_store
arguments: innerHTML,
__gwt_ObjectId: 3497
at
com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChann
elServer.java:
195)
at
com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:
120)
at
com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:
507)
at
com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:
264)
at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.j
ava:
91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:188)
at sun.reflect.GeneratedMethodAccessor12.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at
com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:
71)
at
com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.jav
a:
157)
at
com.google.gwt.dev.shell.BrowserChannel.reactToMessages(BrowserChannel.java :
1669)
at
com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChan
nelServer.java:
401)
at
com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java :
222)
at java.lang.Thread.run(Unknown Source)


I know, it's probably problem with GWT, but if somebody has skills
with GWT and Canviz, could you give me some suggestion please, thanks.

vkrejcirik

unread,
Sep 22, 2010, 8:24:31 AM9/22/10
to canviz
Note:

If I create another HTML object with content:

HTML image = new HTML("<div id=\"debug_output\"></div>");

Then there are any error. But I see anything. There isn't picture
either log message.

vkrejcirik

unread,
Sep 22, 2010, 8:47:26 AM9/22/10
to canviz
I think, that I forgot call:

canviz.draw();

But I still have error:

com.google.gwt.core.client.JavaScriptException: (TypeError): Cannot
read property 'canvasColor' of undefined
stack: TypeError: Cannot read property 'canvasColor' of undefined
at klass.draw (http://127.0.0.1:8889/js/canviz.js:649:36)
at unknown source
at __gwt_jsInvoke (http://127.0.0.1:8889/clan/hosted.html?clan:
70:35)
at eval at <anonymous> (http://127.0.0.1:8889/clan/hosted.html?
clan:54:12)
at XMLHttpRequest.<anonymous> (unknown source)
at unknown source
at __gwt_jsInvoke (http://127.0.0.1:8889/clan/hosted.html?clan:
70:35)
at eval at <anonymous> (http://127.0.0.1:8889/clan/hosted.html?
clan:54:12)
at XMLHttpRequest.onreadystatechange (unknown source)
type: non_object_property_load
arguments: canvasColor,
__gwt_ObjectId: 3290

Ryan Schmidt

unread,
Sep 22, 2010, 3:06:14 PM9/22/10
to can...@googlegroups.com
On Sep 22, 2010, at 07:24, vkrejcirik wrote:

> If I create another HTML object with content:
>
> HTML image = new HTML("<div id=\"debug_output\"></div>");
>
> Then there are any error.

True, Canviz does currently require there to be a div (or other DOM entity) with the id "debug_output" where it should write any error messages it encounters. This is probably a silly thing for Canviz to be doing and I welcome suggestions on how to handle error reporting better; I'm not familiar with what other libraries are doing with JavaScript error reporting these days.

Ryan Schmidt

unread,
Sep 22, 2010, 3:10:56 PM9/22/10
to can...@googlegroups.com

On Sep 22, 2010, at 03:20, vkrejcirik wrote:

> public static native void getImage2(String dot) /*-{
> var canviz;
> canviz = new $wnd.Canviz("image_2");
> canviz.load(dot);
> }-*/;

What is "dot"?

The canviz.load() function expects the URL of a graph file that has been produced by running "dot -Txdot" (or the URL of a script that produces output in that format).

You cannot pass the URL of a graph file that has not been through "dot -Txdot", and you cannot pass the text of the graph itself.

It wasn't clear to me what you're passing as "dot" so I wanted to make sure.


Reply all
Reply to author
Forward
0 new messages