Tuesday, February 19, 2013

Re: How to call javascript mehtod which is defined in another.js file in GWT client

Hello,

I can't get it work. I added the <script> tag to the html hosting page and still get the exception: Cannot call method 'info' of undefined

Thanks

On Tuesday, September 18, 2007 11:46:08 PM UTC, Sumit Chandel wrote:
Hi Rinku,

Actually, your initial setup to include the external JavaScript file using the <script> tag in your module XML file is correct. You would want to include the <script> tag in module XML file rather than in your the host HTML file. GWT takes care to include external resource references such as JavaScript files described in the module XML into the host page namespace as if you had included them explicitly using the <script> HTML element. This is covered in the Developer Guide at the link below:

http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.Fundamentals.Modules.AutomaticResourceInjection.html

As darkAngel described, to start using methods defined in the external JavaScript file as well as to write your own JavaScript you would use GWT's Java Script Native Interface (JSNI). You can read more details on using JSNI in the Developer Guide ate the link below:

http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.JavaScriptNativeInterface.html

Hope that helps,
-Sumit Chandel

On 9/14/07, darkAngel < ab.dar...@gmail.com> wrote:

Hi:

You must include this statement:

<script type="text/javascript" src="js/your_script.js"></script>

in the HTML file not in the XML module. This statement must be
included in the <head> tag before this statement:

<script language='javascript' src='<Name of main module>.nocache.js'></
script>

In your java code you must use JSNI to create a Java method that wraps
the JavaScript method.

public native void methodWrapper()/*- {
    // Invoke your javascript method here.
}-*/;


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment