One way you can bridge a javascript function that is inside a JSNI method to
your js function. Ex.:

In a JSNI:

public void foo_wrapper(JNITest obj)
/*-{
        @com.client.JNITest::testWrapper = function(str)
            {
            [email protected]::foo(Ljava/lang/String;)(str);
            };
        $wnd.register_wrapper(@com.client.JNITest::testWrapper);

-}*/;


In your Test.js:

var wrapperRegistered;

function testWrapper(wrapper) {
    wrapperRegistered = wrapper;
}

function callJavaMethod() {
    wrapper("test");
}

Best
Kevin

On Tue, Dec 16, 2008 at 11:59 PM, Jag <[email protected]> wrote:

>
> I want to call a Java method from my javascript  in a GWT application.
> Here i have a js method in an external javascript file as below
>
> Test.js
>
> function callJavaMethod(){
> }
>
> I have a method in my java file as below,
>
> JNITest.java
>
> public class JNITest{
>
> public void foo(String strTest){
>   ///operations
> }
>
> }
>
> Is it possible to call the foo() from my callJavaMethod() in Test.js
> file. If so how can be done? A sample code would be more helpful.
>
> Thanks.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to