Hi ,

Yes, you are correct. But how can we stop this.And also I may need to use 
the  "callGWTUtils" javascript api with parameter html tag id.

Thanks again for quick reply.

Regards
Manish

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


>
> Seem logic that the callback is called twice ...
> - HTML: onload of your frame with a parameter
> - GWT: onModuleLoad *without* parameter
>
> On Sat, Nov 15, 2008 at 11:40 AM, Manish Kumar <[EMAIL PROTECTED]> 
> wrote:
>>
>>
>> Hi olivier,
>>
>> The code i have written as follows :
>> public void onModuleLoad()
>>
>> {
>>
>>            try{        exportStaticMethod(this); }catch(Exception re){
>>
>>                            MessageBox.alert(re.getMessage());
>>
>>                }
>>
>>        }
>>
>>
>>        public native void exportStaticMethod(PMGWTHtmlUtils 
>> pmGWTHtmlUtils)
>>
>>        /*-{
>>
>>
>>                    $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);
>>
>>                    };
>>
>>
>>                    if($wnd.callGWTUtils){
>>
>>                    $wnd.callGWTUtils();
>>
>>                    }
>>
>>
>>            }-*/;
>>
>> public void invokeGWT( String bId,String cId,String mId,String 
>> mName,String
>> cName ) throws RequestException {
>>
>> System.out.println( " xxxxxxxxxxxxxxxxxxxxxxxxxxxx :"+ bId);
>>
>> }
>>
>> in javascript :
>>
>> function callGWTUtils( bttnId )
>>
>> {
>>
>>                alert('xxxxxxxxxxx'+ bttnId);
>>
>>                invokeGWT(
>> bttnId,"vvvvvvvvvvvvvvvv","vvvvvvvvvvvvvvvv","vvvvvvvvvvvvvvvv","vvvvvvvvvvvvvvvv"
>>  );
>>
>>            /*if( currDispId != null ){
>>
>>            invokeGWT( bttnId,currDispId );
>>
>>            }*/
>>
>> }
>>
>> Html stuffs:
>>
>> <html>
>>
>> <head>
>>
>>
>> <!-- -->
>>
>> <!-- Any title is fine -->
>>
>> <!-- -->
>>
>> <title>PM HTML-GWT Wrapper</title>
>>
>>
>> <!-- -->
>>
>> <!-- The module reference below is the link -->
>>
>> <!-- between html and your Web Toolkit module -->
>>
>> <!-- -->
>>
>> <meta name='gwt:module'
>> content='com.pm.output.html.gwt.model.comment.PMGWTHtmlUtils'></meta>
>>
>>
>> <!-- -->
>>
>> <!-- Link CSS file -->
>>
>> <!-- -->
>>
>> <link type="text/css" rel='stylesheet' href='ExGwtExt.css'></link>
>>
>>
>> <link rel="stylesheet" type="text/css"
>> href="js/ext/resources/css/ext-all.css"></link>
>>
>>
>> <link rel="stylesheet" type="text/css"
>> href="js/ext/resources/css/xtheme-aero.css"/></link>
>>
>>
>> <script type="text/javascript"
>> src="js/ext/adapter/yui/yui-utilities.js"></script>
>>
>>
>> <script type="text/javascript"
>> src="js/ext/adapter/yui/ext-yui-adapter.js"></script>
>>
>>
>> <script src="js/sh/shCore.js"></script>
>>
>>
>> <script src="js/sh/shBrushJava.js"></script>
>>
>>
>> <style>
>>
>> * {
>>
>> font-family:Courier New,monospace;
>>
>> padding: 0;
>>
>> margin: 0;
>>
>> white-space: nowrap;
>>
>> font-size: 11px;
>>
>> }
>>
>>
>> .dp-highlighter
>>
>> {
>>
>> white-space: nowrap;
>>
>> overflow: visible;
>>
>> width: 600px;
>>
>> font-size: 11px;
>>
>> font-family:Courier New,monospace;
>>
>> }
>>
>> </style>
>>
>> </head>
>>
>>
>> <!-- -->
>>
>> <!-- The body can have arbitrary html, or -->
>>
>> <!-- we leave the body empty because we want -->
>>
>> <!-- to create a completely dynamic ui -->
>>
>> <!-- -->
>>
>> <body>
>>
>> <script type="text/javascript" src="js/ext/ext-all.js"></script>
>>
>>
>> <script type="text/javascript" src="js/ext/ext-base.js"></script>
>>
>> <!-- -->
>>
>> <!-- This script is required bootstrap stuff. -->
>>
>> <!-- You can put it in the HEAD, but startup -->
>>
>> <!-- is slightly faster if you include it here. -->
>>
>> <!-- -->
>>
>> <script language="javascript"
>> src="com.pm.output.html.gwt.model.comment.PMGWTHtmlUtils.nocache.js"></script>
>>
>> <script language="javascript" src="js/ext/pmxslutils.js"></script>
>>
>> <iframe onload="javascript:callGWTUtils('v7')"/>
>>
>>
>> </body>
>>
>> </html>
>>
>> Please let us know where i am wrong.
>> Regards
>>
>> Manish
>>
>>
>> ----- Original Message -----
>> From: "olivier nouguier" <[EMAIL PROTECTED]>
>> To: <[email protected]>
>> Sent: Saturday, November 15, 2008 3:43 PM
>> Subject: Re: Problem with JSNI call to java method from javascript
>>
>>
>>>
>>> On Sat, Nov 15, 2008 at 8:31 AM, Manish Kumar <[EMAIL PROTECTED]>
>>> wrote:
>>>>
>>>> Hi,
>>>>
>>>> Thanks for your much needed help.
>>> U welcome :)
>>>> This seems working but it calls the same method twice so my original
>>>> value
>>>> is lost.
>>> Strange could you send me your code ?
>>>> 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.
>>>>>
>>>>> >
>>>>
>>>>
>>>> >
>>>>
>>>
>>>
>>>
>>> --
>>> 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