JsInterop callback function with parameters

2015-09-24 Thread Cristian Rinaldi
Hey:
  
   I'm using JsInterop to map some JS APIs.
What is the best way to map a callback to receive multiple parameters?

For example, a jQuery click handler: function (event, params)

Java could be:
  Function (Event, Object []), but then is complicated to manipulate the 
"Object []", there is a more direct way?

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@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.
For more options, visit https://groups.google.com/d/optout.


Callback Function

2010-09-14 Thread gadaleta.marco
Hi,
I've a big problem, and i've not solution.
This my problem: i have 2 class A and B.
A call B, and  B execute an asyncronous call. On result event i need
to call A method from B.
There's a way to set a callback function in A for B class?


I hope in your help.
Thx, Marco

-- 
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-tool...@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.



Re: Callback Function

2010-09-14 Thread Marco Gadaleta
I fixed it ;-)

2010/9/14 gadaleta.marco gadaleta.ma...@gmail.com

 Hi,
 I've a big problem, and i've not solution.
 This my problem: i have 2 class A and B.
 A call B, and  B execute an asyncronous call. On result event i need
 to call A method from B.
 There's a way to set a callback function in A for B class?


 I hope in your help.
 Thx, Marco




-- 
Marco

-- 
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-tool...@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.



Re: Callback function implemented in Java

2009-09-15 Thread JaM

Not sure if this helps or not, but it seems that when performing the
callback I don't have any access to member variables which are not
declared final (and can't access the parents variables at all if I use
an inner class).  This seems strange that I wouldn't be able to access
non final member variables from my class.  As a test I created a
simple string and initialize it's value to blah, but whenever I
attempt to access it for the first time I get undefined.  If I then
set the variable, the next time the event is thrown and the method is
called the value gets updated to what I set, but this initial
undefined state is an issue for me.  Are there any ways to work around
or fix this?

On Sep 14, 10:24 pm, JaM jej2...@gmail.com wrote:
 I previously posted about Shindig, when probably more appropriately I
 should have posted this question (sorry for the dup).

 I have successfully implemented acallbackin Java (using an
 interface) which is called from Javascript appropriately, but after
 doing so it seems something is not quite right (perhaps the scope, not
 really sure how to determine).  The issue is that I now get an error
 that says something like jV(this.a.a...) and it throws an error saying
 this.a is undefined.  The issue only happens when I am trying to
 access instance variables inside my java code.  If I do not access
 instance variables everything works fine, which leads me to believe it
 may be a scoping issue.  Is there a general rule of thumb for how to
 do this correctly in GWT?  Any pointers would be greatly appreciated.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Callback function implemented in Java

2009-09-15 Thread Thomas Broyer


On 15 sep, 04:24, JaM jej2...@gmail.com wrote:
 I previously posted about Shindig, when probably more appropriately I
 should have posted this question (sorry for the dup).

 I have successfully implemented a callback in Java (using an
 interface) which is called from Javascript appropriately, but after
 doing so it seems something is not quite right (perhaps the scope, not
 really sure how to determine).  The issue is that I now get an error
 that says something like jV(this.a.a...) and it throws an error saying
 this.a is undefined.  The issue only happens when I am trying to
 access instance variables inside my java code.  If I do not access
 instance variables everything works fine, which leads me to believe it
 may be a scoping issue.  Is there a general rule of thumb for how to
 do this correctly in GWT?  Any pointers would be greatly appreciated.

This generally works:

public interface MyCallback {
   void callback(int a, int b, String c);
}

public native void doSomething(MyCallback callback) /*-{
$wnd.doSomething(function(a, b, c) {
callba...@my.package.mycallback::callback(IILjava/lang/String;)
(a, b, c);
});
}-*/;

Actually, you'd generally call some static method that uses the
UncaughtExceptionHandler if there's one:
public native void doSomething(MyCallback callback) /*-{
$wnd.doSomething(function(a, b, c) {
@my.package.MyClass::callback(Lmy/package/MyCallback;IILjava/
lang/String;)(a, b, c, callback);
});
}-*/;
private static void callback(MyCallback callback, int a, int b, String
c) {
   UncaughtExceptionHandler handler = GWT.getUncaughtExceptionHandler
();
   if (handler != null) {
  callbackImpl(callback, a, b, c);
   } else {
  callbackAndCatch(handler, callback, a, b, c);
   }
}
private static void callbackImpl(MyCallback callback, int a, int b,
String c) {
   callback.callback(a, b, c);
}
private static void callbackAndCatch(UncaughtExceptionHandler handler,
MyCallback callback, int a, int b, String c) {
   try {
  callbackImpl(callback, a, b, c);
   } catch (Throwable t) {
  handler.onUncaughtException(t);
   }
}

..and finally, if your callback is this:
public native void doSomething() /*-{
   var that = this;
   $wnd.doSomething(function(a, b, c) {
 @my.package.MyClass::callback(Lmy/package/MyCallback;IILjava/lang/
String;)(that, a, b, c);
   });
}-*/;


You'll find those patterns several times in GWT itself, as well as in
other GWT libraries wrapping JavaScript libs (GALGWT, GWT-in-the-AIR,
etc.)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Callback function implemented in Java

2009-09-15 Thread JaM

Thanks for the reply!  I am trying to digest this as I am new to GWT
and Javascript so please bare with me.


Ok, so clearly I am missing something here.  Currently I am not
calling static methods (is this required?) for the callback because I
want to be able to access member variables.  I have the following

public interface EventHandler {
   void onEvent(String channel, String message);
}

native void nativeMethod(String channel, EventHandler handler) /*-{
$wnd.subscribe(channel, 
handl...@my.package.eventhandler::onEvent
(Ljava/lang/String;Ljava/lang/String;));
}-*/;


but when the onEvent gets called I can only access some final
variables (none of the GXT members can be accessed, really only public
strings).  In order to make this work I have to make my member
variables static, otherwise everything comes up as undefined, which is
why I believe this is a scope issue.  Should what I am doing work?

I am also trying to do the following (which I think is your
suggestion)
native void nativeSubscribe(String channel, EventHandler handler) /*-{
var that = handler;
$wnd.subscribe(function(channel, handler) {

handl...@my.package.eventhandler::onEvent(Ljava/lang/String;Ljava/
lang/String;)(that, channel, message);
});
}-*/;
but that did not work at all.  Any thoughts?


On Sep 15, 10:23 am, Thomas Broyer t.bro...@gmail.com wrote:
 On 15 sep, 04:24,JaMjej2...@gmail.com wrote:

  I previously posted about Shindig, when probably more appropriately I
  should have posted this question (sorry for the dup).

  I have successfully implemented a callback in Java (using an
  interface) which is called from Javascript appropriately, but after
  doing so it seems something is not quite right (perhaps the scope, not
  really sure how to determine).  The issue is that I now get an error
  that says something like jV(this.a.a...) and it throws an error saying
  this.a is undefined.  The issue only happens when I am trying to
  access instance variables inside my java code.  If I do not access
  instance variables everything works fine, which leads me to believe it
  may be a scoping issue.  Is there a general rule of thumb for how to
  do this correctly in GWT?  Any pointers would be greatly appreciated.

 This generally works:

 public interface MyCallback {
    void callback(int a, int b, String c);

 }

 public native void doSomething(MyCallback callback) /*-{
     $wnd.doSomething(function(a, b, c) {
         callba...@my.package.mycallback::callback(IILjava/lang/String;)
 (a, b, c);
     });

 }-*/;

 Actually, you'd generally call some static method that uses the
 UncaughtExceptionHandler if there's one:
 public native void doSomething(MyCallback callback) /*-{
     $wnd.doSomething(function(a, b, c) {
         @my.package.MyClass::callback(Lmy/package/MyCallback;IILjava/
 lang/String;)(a, b, c, callback);
     });}-*/;

 private static void callback(MyCallback callback, int a, int b, String
 c) {
    UncaughtExceptionHandler handler = GWT.getUncaughtExceptionHandler
 ();
    if (handler != null) {
       callbackImpl(callback, a, b, c);
    } else {
       callbackAndCatch(handler, callback, a, b, c);
    }}

 private static void callbackImpl(MyCallback callback, int a, int b,
 String c) {
    callback.callback(a, b, c);}

 private static void callbackAndCatch(UncaughtExceptionHandler handler,
 MyCallback callback, int a, int b, String c) {
    try {
       callbackImpl(callback, a, b, c);
    } catch (Throwable t) {
       handler.onUncaughtException(t);
    }

 }

 ..and finally, if your callback is this:
 public native void doSomething() /*-{
    var that = this;
    $wnd.doSomething(function(a, b, c) {
     �...@my.package.myclass::callback(Lmy/package/MyCallback;IILjava/lang/
 String;)(that, a, b, c);
    });

 }-*/;

 You'll find those patterns several times in GWT itself, as well as in
 other GWT libraries wrapping JavaScript libs (GALGWT, GWT-in-the-AIR,
 etc.)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Callback function implemented in Java

2009-09-15 Thread JaM

also, unless I am doing something wrong the above does not seem to
work properly

I get an error on compile saying [ERROR] Line 50:  Expected a valid
parameter type signature in JSNI method reference which is pointing at
the nativeSubscribe method.  Again your help is appreciated.


public native void nativeSubscribe(String channel, EventHandler
callback) /*-{
$wnd.subscribe(function(channel) {
@my.package.EventingController::callback
(Lmy.package.EventHandler;Ljava/lang/String;Ljava/lang/String;)
(channel, callback);
});
}-*/;

private static void callback(EventHandler callback, String sender,
String message) {
UncaughtExceptionHandler handler = 
GWT.getUncaughtExceptionHandler
();
if (handler == null) {
callbackImpl(callback, sender, message);
} else {
callbackAndCatch(handler, callback, sender, message);
}
}

private static void callbackImpl(EventHandler callback, String
sender,
String message) {
callback.onEvent(sender, message);
}

private static void callbackAndCatch(UncaughtExceptionHandler
handler,
EventHandler callback, String sender, String message) {
try {
callbackImpl(callback, sender, message);
} catch (Throwable t) {
handler.onUncaughtException(t);
}

}

On Sep 15, 11:21 am, JaM jej2...@gmail.com wrote:
 Thanks for the reply!  I am trying to digest this as I am new to GWT
 and Javascript so please bare with me.

 Ok, so clearly I am missing something here.  Currently I am not
 calling static methods (is this required?) for the callback because I
 want to be able to access member variables.  I have the following

 public interface EventHandler {
    void onEvent(String channel, String message);

 }

         native void nativeMethod(String channel, EventHandler handler) /*-{
                 $wnd.subscribe(channel, 
 handl...@my.package.eventhandler::onEvent
 (Ljava/lang/String;Ljava/lang/String;));
         }-*/;

 but when the onEvent gets called I can only access some final
 variables (none of the GXT members can be accessed, really only public
 strings).  In order to make this work I have to make my member
 variables static, otherwise everything comes up as undefined, which is
 why I believe this is a scope issue.  Should what I am doing work?

 I am also trying to do the following (which I think is your
 suggestion)
 native void nativeSubscribe(String channel, EventHandler handler) /*-{
         var that = handler;
         $wnd.subscribe(function(channel, handler) {
                 
 handl...@my.package.eventhandler::onEvent(Ljava/lang/String;Ljava/
 lang/String;)(that, channel, message);
         });}-*/;

 but that did not work at all.  Any thoughts?

 On Sep 15, 10:23 am, Thomas Broyer t.bro...@gmail.com wrote:

  On 15 sep, 04:24,JaMjej2...@gmail.com wrote:

   I previously posted about Shindig, when probably more appropriately I
   should have posted this question (sorry for the dup).

   I have successfully implemented a callback in Java (using an
   interface) which is called from Javascript appropriately, but after
   doing so it seems something is not quite right (perhaps the scope, not
   really sure how to determine).  The issue is that I now get an error
   that says something like jV(this.a.a...) and it throws an error saying
   this.a is undefined.  The issue only happens when I am trying to
   access instance variables inside my java code.  If I do not access
   instance variables everything works fine, which leads me to believe it
   may be a scoping issue.  Is there a general rule of thumb for how to
   do this correctly in GWT?  Any pointers would be greatly appreciated.

  This generally works:

  public interface MyCallback {
     void callback(int a, int b, String c);

  }

  public native void doSomething(MyCallback callback) /*-{
      $wnd.doSomething(function(a, b, c) {
          callba...@my.package.mycallback::callback(IILjava/lang/String;)
  (a, b, c);
      });

  }-*/;

  Actually, you'd generally call some static method that uses the
  UncaughtExceptionHandler if there's one:
  public native void doSomething(MyCallback callback) /*-{
      $wnd.doSomething(function(a, b, c) {
          @my.package.MyClass::callback(Lmy/package/MyCallback;IILjava/
  lang/String;)(a, b, c, callback);
      });}-*/;

  private static void callback(MyCallback callback, int a, int b, String
  c) {
     UncaughtExceptionHandler handler = GWT.getUncaughtExceptionHandler
  ();
     if (handler != null) {
        callbackImpl(callback, a, b, c);
     } else {
        callbackAndCatch(handler, callback, a, b, c);
     }}

  private static void callbackImpl(MyCallback callback, int a, int b,
  String 

Re: Callback function implemented in Java

2009-09-15 Thread JaM

typohave .'s instead of /'s in the JSNI...fixed an am trying now

On Sep 15, 12:21 pm, JaM jej2...@gmail.com wrote:
 also, unless I am doing something wrong the above does not seem to
 work properly

 I get an error on compile saying [ERROR] Line 50:  Expected a valid
 parameter type signature in JSNI method reference which is pointing at
 the nativeSubscribe method.  Again your help is appreciated.

         public native void nativeSubscribe(String channel, EventHandler
 callback) /*-{
                 $wnd.subscribe(function(channel) {
                 @my.package.EventingController::callback
 (Lmy.package.EventHandler;Ljava/lang/String;Ljava/lang/String;)
 (channel, callback);
                 });
         }-*/;

         private static void callback(EventHandler callback, String sender,
 String message) {
                 UncaughtExceptionHandler handler = 
 GWT.getUncaughtExceptionHandler
 ();
                 if (handler == null) {
                         callbackImpl(callback, sender, message);
                 } else {
                         callbackAndCatch(handler, callback, sender, message);
                 }
         }

         private static void callbackImpl(EventHandler callback, String
 sender,
                         String message) {
                 callback.onEvent(sender, message);
         }

         private static void callbackAndCatch(UncaughtExceptionHandler
 handler,
                         EventHandler callback, String sender, String message) 
 {
                 try {
                         callbackImpl(callback, sender, message);
                 } catch (Throwable t) {
                         handler.onUncaughtException(t);
                 }

         }

 On Sep 15, 11:21 am,JaMjej2...@gmail.com wrote:

  Thanks for the reply!  I am trying to digest this as I am new to GWT
  and Javascript so please bare with me.

  Ok, so clearly I am missing something here.  Currently I am not
  calling static methods (is this required?) for the callback because I
  want to be able to access member variables.  I have the following

  public interface EventHandler {
     void onEvent(String channel, String message);

  }

          native void nativeMethod(String channel, EventHandler handler) /*-{
                  $wnd.subscribe(channel, 
  handl...@my.package.eventhandler::onEvent
  (Ljava/lang/String;Ljava/lang/String;));
          }-*/;

  but when the onEvent gets called I can only access some final
  variables (none of the GXT members can be accessed, really only public
  strings).  In order to make this work I have to make my member
  variables static, otherwise everything comes up as undefined, which is
  why I believe this is a scope issue.  Should what I am doing work?

  I am also trying to do the following (which I think is your
  suggestion)
  native void nativeSubscribe(String channel, EventHandler handler) /*-{
          var that = handler;
          $wnd.subscribe(function(channel, handler) {
                  
  handl...@my.package.eventhandler::onEvent(Ljava/lang/String;Ljava/
  lang/String;)(that, channel, message);
          });}-*/;

  but that did not work at all.  Any thoughts?

  On Sep 15, 10:23 am, Thomas Broyer t.bro...@gmail.com wrote:

   On 15 sep, 04:24,JaMjej2...@gmail.com wrote:

I previously posted about Shindig, when probably more appropriately I
should have posted this question (sorry for the dup).

I have successfully implemented a callback in Java (using an
interface) which is called from Javascript appropriately, but after
doing so it seems something is not quite right (perhaps the scope, not
really sure how to determine).  The issue is that I now get an error
that says something like jV(this.a.a...) and it throws an error saying
this.a is undefined.  The issue only happens when I am trying to
access instance variables inside my java code.  If I do not access
instance variables everything works fine, which leads me to believe it
may be a scoping issue.  Is there a general rule of thumb for how to
do this correctly in GWT?  Any pointers would be greatly appreciated.

   This generally works:

   public interface MyCallback {
      void callback(int a, int b, String c);

   }

   public native void doSomething(MyCallback callback) /*-{
       $wnd.doSomething(function(a, b, c) {
           callba...@my.package.mycallback::callback(IILjava/lang/String;)
   (a, b, c);
       });

   }-*/;

   Actually, you'd generally call some static method that uses the
   UncaughtExceptionHandler if there's one:
   public native void doSomething(MyCallback callback) /*-{
       $wnd.doSomething(function(a, b, c) {
           @my.package.MyClass::callback(Lmy/package/MyCallback;IILjava/
   lang/String;)(a, b, c, callback);
       });}-*/;

   private static void callback(MyCallback callback, int a, int b, String
   c) {
      UncaughtExceptionHandler handler = GWT.getUncaughtExceptionHandler
   ();
    

Re: Callback function implemented in Java

2009-09-15 Thread JaM

Ok, so after doing what was listed above it seems as if the scope is
correct.  It's a little strange to me that what I was doing originally
did not work but having this work makes me very happy.  Thank you for
your help, it really is appreciated.

On Sep 15, 12:23 pm, JaM jej2...@gmail.com wrote:
 typohave .'s instead of /'s in the JSNI...fixed an am trying now

 On Sep 15, 12:21 pm,JaMjej2...@gmail.com wrote:

  also, unless I am doing something wrong the above does not seem to
  work properly

  I get an error on compile saying [ERROR] Line 50:  Expected a valid
  parameter type signature in JSNI method reference which is pointing at
  the nativeSubscribe method.  Again your help is appreciated.

          public native void nativeSubscribe(String channel, EventHandler
  callback) /*-{
                  $wnd.subscribe(function(channel) {
                  @my.package.EventingController::callback
  (Lmy.package.EventHandler;Ljava/lang/String;Ljava/lang/String;)
  (channel, callback);
                  });
          }-*/;

          private static void callback(EventHandler callback, String sender,
  String message) {
                  UncaughtExceptionHandler handler = 
  GWT.getUncaughtExceptionHandler
  ();
                  if (handler == null) {
                          callbackImpl(callback, sender, message);
                  } else {
                          callbackAndCatch(handler, callback, sender, 
  message);
                  }
          }

          private static void callbackImpl(EventHandler callback, String
  sender,
                          String message) {
                  callback.onEvent(sender, message);
          }

          private static void callbackAndCatch(UncaughtExceptionHandler
  handler,
                          EventHandler callback, String sender, String 
  message) {
                  try {
                          callbackImpl(callback, sender, message);
                  } catch (Throwable t) {
                          handler.onUncaughtException(t);
                  }

          }

  On Sep 15, 11:21 am,JaMjej2...@gmail.com wrote:

   Thanks for the reply!  I am trying to digest this as I am new to GWT
   and Javascript so please bare with me.

   Ok, so clearly I am missing something here.  Currently I am not
   calling static methods (is this required?) for the callback because I
   want to be able to access member variables.  I have the following

   public interface EventHandler {
      void onEvent(String channel, String message);

   }

           native void nativeMethod(String channel, EventHandler handler) 
   /*-{
                   $wnd.subscribe(channel, 
   handl...@my.package.eventhandler::onEvent
   (Ljava/lang/String;Ljava/lang/String;));
           }-*/;

   but when the onEvent gets called I can only access some final
   variables (none of the GXT members can be accessed, really only public
   strings).  In order to make this work I have to make my member
   variables static, otherwise everything comes up as undefined, which is
   why I believe this is a scope issue.  Should what I am doing work?

   I am also trying to do the following (which I think is your
   suggestion)
   native void nativeSubscribe(String channel, EventHandler handler) /*-{
           var that = handler;
           $wnd.subscribe(function(channel, handler) {
                   
   handl...@my.package.eventhandler::onEvent(Ljava/lang/String;Ljava/
   lang/String;)(that, channel, message);
           });}-*/;

   but that did not work at all.  Any thoughts?

   On Sep 15, 10:23 am, Thomas Broyer t.bro...@gmail.com wrote:

On 15 sep, 04:24,JaMjej2...@gmail.com wrote:

 I previously posted about Shindig, when probably more appropriately I
 should have posted this question (sorry for the dup).

 I have successfully implemented a callback in Java (using an
 interface) which is called from Javascript appropriately, but after
 doing so it seems something is not quite right (perhaps the scope, not
 really sure how to determine).  The issue is that I now get an error
 that says something like jV(this.a.a...) and it throws an error saying
 this.a is undefined.  The issue only happens when I am trying to
 access instance variables inside my java code.  If I do not access
 instance variables everything works fine, which leads me to believe it
 may be a scoping issue.  Is there a general rule of thumb for how to
 do this correctly in GWT?  Any pointers would be greatly appreciated.

This generally works:

public interface MyCallback {
   void callback(int a, int b, String c);

}

public native void doSomething(MyCallback callback) /*-{
    $wnd.doSomething(function(a, b, c) {
        callba...@my.package.mycallback::callback(IILjava/lang/String;)
(a, b, c);
    });

}-*/;

Actually, you'd generally call some static method that uses the
UncaughtExceptionHandler if there's 

Callback function implemented in Java

2009-09-14 Thread JaM

I previously posted about Shindig, when probably more appropriately I
should have posted this question (sorry for the dup).

I have successfully implemented a callback in Java (using an
interface) which is called from Javascript appropriately, but after
doing so it seems something is not quite right (perhaps the scope, not
really sure how to determine).  The issue is that I now get an error
that says something like jV(this.a.a...) and it throws an error saying
this.a is undefined.  The issue only happens when I am trying to
access instance variables inside my java code.  If I do not access
instance variables everything works fine, which leads me to believe it
may be a scoping issue.  Is there a general rule of thumb for how to
do this correctly in GWT?  Any pointers would be greatly appreciated.

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