Thank you Jeff and Bigous for your great help! It is solved.
Regards. Luciano Luciano On 5 août, 16:43, Bigous <big...@gmail.com> wrote: > Hi Luciano, > > Jeff is correct. The script that runs inside the HTML runs before the > script inside your EntryPoint class. > You can check this setting up a timeOut to call a function inside the > html... I changed your code to see how it works... > > ... After the including GWT script... > <script> > var count = 0; > function doStuff() { > count++; > try { > alert('Entered ' + count); > alert(myJavaStaticMethod(1,2)); > } catch(err) {} > } > </script> > </head> > > <!-- --> > <!-- The body can have arbitrary html, or --> > <!-- you can leave the body empty if you want --> > <!-- to create a completely dynamic UI. --> > <!-- --> > <body onload="javascript:doStuff();"> > > <!-- OPTIONAL: include this if you want history support --> > <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' > style="position:absolute;width:0;height:0;border:0"></iframe> > > <script type="text/javascript" language="javascript"> > setTimeout("doStuff()", 1000); > doStuff(); > </script> > </body> > </html> > > We can see 'Entered 1' without the result. This occurs while the > browser is loading the HTML. > We can see 'Entered 2' without the result. This occurs in the bodys > event onload. > We can see 'Entered 3' with the result 3. This occurs in the timeout > event. > > So, you're calling the function before it has been defined. > > Best regards, > Richard Natal > > On Aug 4, 6:06 pm, Jeff Chimene <jchim...@gmail.com> wrote: > > > On 08/04/2009 01:24 PM, Luciano Broussal wrote: > > > > Line 49: Object expected > > > Char : 9 > > > Code: 0 > > > URL : url of myjsni.html test file > > > My guess is that the entire environment has not been created, hence the > > "object expected" error. What I'm saying is that the GWT-generated code > > that loads the $wnd.myJavaStaticMethod runs after the scripts in the > > body tag. > > You can try something like "if (window.sum) sum(3,3);" to prove this. > > > You won't usually use GWT in the style of putting scripts in the body > > tag. You'll usually load the scripts via the head tag. Even when > > retrofitting existing systems, this is the common technique. > > > > HTH Help > > > > On Aug 4, 9:33 pm, Jeff Chimene <jchim...@gmail.com> wrote: > > >> On 08/04/2009 12:23 PM, Luciano Broussal wrote: > > > >>> Hi Jeff, > > > >>> I got a blank page and the myJavaStaticMethod is never called or on > > >>> IE i got the javascript error icon on left bottom corner. > > > >> What's the text associated with this error? > > > >>> I don't really now what is going wrong. Can you make it work on your > > >>> side ? ... > > > >>> Thanks > > > >>> Luciano > > > >>> On Aug 4, 8:31 pm, Jeff Chimene <jchim...@gmail.com> wrote: > > >>>> On 08/04/2009 10:41 AM, Luciano Broussal wrote: > > > >>>>> Hi all, > > > >>>>> I'm fighting withJSNIfor a time without success trying to call a > > >>>>> java method from my javascript stuff. > > > >>>>> I did as explained online but without success :( > > > >>>>>http://code.google.com/docreader/#p(google-web-toolkit-doc-1-5)s(goog...) > > > >>>>> He is my class and html. > > > >>>>> This makes me crazy. If someone could help me to display 1+ 2 = 3 > > >>>>> please. > > > >>>> What symptoms does this derangement exhibit? > > > >>>>> Thanks > > > >>>>> Luciano > > > >>>>> CLASS > > >>>>> ********** > > > >>>>> package com.st.jsni.client; > > > >>>>> import com.google.gwt.core.client.EntryPoint; > > > >>>>> /** > > >>>>> * Entry point classes define <code>onModuleLoad()</code>. > > >>>>> */ > > >>>>> public classJsniimplements EntryPoint { > > >>>>> �...@override > > >>>>> public void onModuleLoad() { > > >>>>> exportStaticMethod(); > > >>>>> } > > > >>>>> public static native void exportStaticMethod() /*-{ > > >>>>> $wnd.myJavaStaticMethod = > > >>>>> @com.st.jsni.client.Jsni::sum(II); > > >>>>> }-*/; > > > >>>>> public static int sum(int a, int b) { > > >>>>> return a + b; > > >>>>> } > > >>>>> } > > > >>>>> HTML > > >>>>> ************* > > > >>>>> <html> > > >>>>> <head> > > >>>>> <meta http-equiv="content-type" content="text/html; > > >>>>> charset=UTF-8"> > > >>>>> <link type="text/css" rel="stylesheet" href="Jsni.css"> > > >>>>> <title>Web Application Starter Project</title> > > >>>>> <script type="text/javascript" language="javascript" src="jsni/ > > >>>>>jsni.nocache.js"></script> > > >>>>> </head> > > > >>>>> <!-- --> > > >>>>> <!-- The body can have arbitrary html, or --> > > >>>>> <!-- you can leave the body empty if you want --> > > >>>>> <!-- to create a completely dynamic UI. --> > > >>>>> <!-- --> > > >>>>> <body> > > > >>>>> <!-- OPTIONAL: include this if you want history support --> > > >>>>> <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' > > >>>>> style="position:absolute;width:0;height:0;border:0"></iframe> > > > >>>>> <script type="text/javascript" language="javascript"> > > >>>>> alert(myJavaStaticMethod(1,2)); > > >>>>> </script> > > >>>>> </body> > > >>>>> </html> --~--~---------~--~----~------------~-------~--~----~ 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 google-web-toolkit+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---