Re: Problem with javascript accessing Java fct.

2008-10-10 Thread Mogoye

Thx for all. You're right.
I'm now calling my method not in a static way but in a 1th javascript
method "start".
"Start" is called by java at startup and now it works.

Thanks again.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



RE: Problem with javascript accessing Java fct.

2008-10-10 Thread Perelman Nathan (Nathan)

Actually, now that I think about it, I'm pretty sure that the code in
onModuleLoad doesn't get run until after the page is fully loaded. So
you can't have static JavaScript in your HTML that runs right away call
functions exported from Java that aren't there until after the page
loads. You could use more JSNI code to call a start function in
JavaScript from onModuleLoad after you call exportStaticMethod. I
believe that that would work.

-Original Message-
From: Google-Web-Toolkit@googlegroups.com
[mailto:[EMAIL PROTECTED] On Behalf Of Mogoye
Sent: Friday, October 10, 2008 10:54
To: Google Web Toolkit
Subject: Re: Problem with javascript accessing Java fct.


Thx for your very fast answer.

But't it does not resolve the problem, I've got the same error.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



Re: Problem with javascript accessing Java fct.

2008-10-10 Thread Mogoye

Thx for your very fast answer.

But't it does not resolve the problem, I've got the same error.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



RE: Problem with javascript accessing Java fct.

2008-10-10 Thread Perelman Nathan (Nathan)

Try putting the call to getJavaValue() (in the html) after you include
the nocache.js file.

-Original Message-
From: Google-Web-Toolkit@googlegroups.com
[mailto:[EMAIL PROTECTED] On Behalf Of Mogoye
Sent: Friday, October 10, 2008 10:44
To: Google Web Toolkit
Subject: Problem with javascript accessing Java fct.


I'm trying to call a Java method form a part of Javascript code.
I've read Accessing Java Methods and Fields from JavaScript and I
think I've reproduced something equivalent but it does not work.

Here is my HTML page :


  


var abcd = getJavaValue();


  
  
  


Here is the java code :
package com.eloquant.test.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;

public class Test implements EntryPoint {

public void onModuleLoad() {

exportStaticMethod();

RootPanel.get().add(new HTML ("abcd =" + getAbcd()));
}

public static int getValue() {
return 1;
};

public static native void exportStaticMethod() /*-{
   $wnd.getJavaValue = @com.eloquant.test.client.Test::getValue();
}-*/;

public native int getAbcd () /*-{
return $wnd.abcd;
}-*/;
}


When I run the app I get the following error :
com.google.gwt.dev.shell.HostedModeException: Expected primitive type
int; actual value was undefined
at com.google.gwt.dev.shell.JsValueGlue.get(JsValueGlue.java:51)
at
com.google.gwt.dev.shell.ModuleSpace.invokeNativeInt(ModuleSpace.java:
193)...


If I replace in the HTML
var abcd = getJavaValue();
By
var abcd = 5;

I've got a correct display, so Java calling Javascript is Ok, but I
don't understand what's wrong with javascript calling java.

Does any one have some ideas ?
Thanks for reading






--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---