Hi,

Thanks for your much needed help.
This seems working but it calls the same method twice so my original value 
is lost.
Any idea about this.

Regards
Manish

----- Original Message ----- 
From: "olivier nouguier" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, November 14, 2008 10:07 PM
Subject: Re: Problem with JSNI call to java method from javascript


>
> hum it should works ... (you don't give the "this" reference" ...
>
> Here a full sample that work :)
>
> ### GWT module
> package test.client;
>
> import com.google.gwt.core.client.EntryPoint;
> import com.google.gwt.user.client.Window;
>
> public class MyModule implements EntryPoint {
>
> public void onModuleLoad() {
>
> init(this);
>
> }
>
> public void gwtFunction(String message) {
> Window.alert(message);
> }
>
> private native void init(MyModule zis) /*-{
>
>      $wnd.injectedFunction = function(message){
> 
> [EMAIL PROTECTED]::gwtFunction(Ljava/lang/String;)(message)
>      }
>
>   if($wnd.jsOnload){
>      $wnd.jsOnload();
>   }
>
> }-*/;
>
> }
>
> ###
>
> ### HTML hosted page ###
> <html>
> <head>
>
> <!--                                           -->
> <!-- Any title is fine                         -->
> <!--                                           -->
> <title>Wrapper HTML for MyModule</title>
>
> <!--                                           -->
> <!-- Use normal html, such as style            -->
> <!--                                           -->
> <style>
> body,td,a,div,.p{font-family:arial,sans-serif}
> div,td{color:#000000}
> a:link,.w,.w a:link{color:#0000cc}
> a:visited{color:#551a8b}
> a:active{color:#ff0000}
> </style>
>
> <!--                                           -->
> <!-- This script loads your compiled module.   -->
> <!-- If you add any GWT meta tags, they must   -->
> <!-- be added before this line.                -->
> <!--                                           -->
> </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"
> style="width:0;height:0;border:0"></iframe>
>
>   <script type="text/javascript" language="javascript"
> src="test.MyModule.nocache.js"></script>
>   <script type="text/javascript">
>   function jsOnload(){
>   injectedFunction("Helo");
>   }
>   </script>
>
> </body>
> </html>
> ###
>
> On Fri, Nov 14, 2008 at 3:37 PM, Manish Kumar <[EMAIL PROTECTED]> 
> wrote:
>>
>> Hi olivier,
>>
>> Thanks for your kind help.
>>
>> I tried this , this does not work with the exception
>> Could not find a native method with the signature
>> '@com.pm.output.html.gwt.model.comment.client.PMGWTHtmlUtils::exportStaticMethod()'
>>
>> which was not coming before.
>>
>> Please let us know where am I conceptually wrong.If anybody have 
>> alternative
>> idea , plz pass it.
>>
>> Regards
>> Manish
>>
>>
>> ----- Original Message -----
>> From: "olivier nouguier" <[EMAIL PROTECTED]>
>> To: <[email protected]>
>> Sent: Friday, November 14, 2008 7:36 PM
>> Subject: Re: Problem with JSNI call to java method from javascript
>>
>>
>>>
>>> Hi,
>>> I suspect (?) that your js code is call to soon ...
>>> The GWT is not yet initialized
>>>
>>> Please try this:
>>> ### GWT patch ###
>>> static
>>> native void exportStaticMethod()
>>> /*-{
>>> $wnd.invokeGWT = function(bId,cId,mId,mName,cName){
>>> [EMAIL 
>>> PROTECTED]::invokeGWT(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)
>>> (bId,cId,mId,mName,cName);
>>> };
>>> // Lazy call to onLoad
>>> if($wnd.my_onload){
>>>  $wnd.my_onload();
>>> }
>>> }-*/
>>> ;
>>> ### JS Patch in HTML page ####
>>> // This function will be called by GWT module.
>>> function my_onload(){
>>> invokeGWT(
>>> "vvvvvvvvvvvvvvvv","vvvvvvvvvvvvvvvv","vvvvvvvvvvvvvvvv","vvvvvvvvvvvvvvvv","vvvvvvvvvvvvvvvv"
>>> );
>>> }
>>>
>>> By doing this the invokeGWT is call after the module initialise.
>>>
>>> HIH
>>>
>>> --
>>> Si l'ignorance peut servir de consolation, elle n'en est pas moins
>>> illusoire.
>>>
>>> >
>>
>>
>> >
>>
>
>
>
> -- 
> Si l'ignorance peut servir de consolation, elle n'en est pas moins 
> illusoire.
>
> > 


--~--~---------~--~----~------------~-------~--~----~
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