On Wed, Jan 3, 2018 at 8:35 AM, <ka...@bitxenio.com> wrote:

> Hello:
>
>     How can we use that new interface? There's no documentation and our
> current lib doesn't expose said addJSCallback() yet (and updating c1 libs
> didn't help).
>
You need to update your project libs.  It should be there (just tested on a
project here).  (I.e. Project Properties > Update Project Libs .. not
"update cn1libs")


> Also, is the fix already available in the build servers?
>
No.  It will be up in the next build server update on Friday.

Steve


>
> Kind regards,
>     Kandy.
>
>
> On Wednesday, January 3, 2018 at 2:47:04 PM UTC+1, Steve Hannah wrote:
>>
>> This looks like a race condition that has been there for a while.  I have
>> just committed a fix for it here
>> https://github.com/codenameone/CodenameOne/commit/783ac28284
>> 09aa747103a35001b4886e24944484
>>
>> With the last update, however, the com.codename1.javascript package is
>> now deprecated in favour of a new async API that is incorporated directly
>> into the BrowserComponent class.  I recommend migrating over to this new
>> API for new code, as it will produce much better performance (no hidden
>> invokeAndBlock under the hood - except in xxxAndWait() methods).
>>
>> Using the new API, your code would become:
>>
>> bc.addJSCallback("window.checkfoxClickedCallback ={setChecked:
>> function(){ callback.onSuccess(null)}}", r->{
>>     Log.p("->checkboxClickedCallback.setChecked()");
>>     contexto.mostrarMensaje("checkboxClickedCallback.setChecked()");
>> });
>> bc.addJSCallback("window.okButtonClickedCallback = {showMap: function()
>> { callback.onSuccess(null)}}", r->{
>>      Log.p("->okButtonClickedCallback.showMap()");
>>      contexto.mostrarMensaje("okButtonClickedCallback.showMap()");
>> });
>>
>> Notice, with this new syntax, you reference the java callback explicitly
>> in the javascript code via the "callback" variable, which, in Javascript,
>> contains 2 methods: onSuccess(arg), and onError(message, code).
>>
>> Steve
>>
>>
>>
>>
>> On Wed, Jan 3, 2018 at 5:09 AM, <ka...@bitxenio.com> wrote:
>>
>>> Hello:
>>>
>>>     Since the last codename1 libary update we've been having problems
>>> with the BrowserComponent on iOS. We've narrowed down the problem to the
>>> callback registration process (which gets executed on the BrowserComponent
>>> onLoad callback). We register two functions, but only the second one can be
>>> invoked from javascript. The first one gets registered ok (we can see its
>>> code from the javascript side) but fails to execute on iOS (in Android and
>>> the simulator works fine). We tried a lot of permutations, and different
>>> argument lengths for both functions, but the only difference we see is the
>>> registration order. If we switch the registration order, we can only invoke
>>> the other one (whichever gets registered last).
>>>
>>> /*
>>> * Registramos el callback JS de valor cambiado del checkbox "No volver a
>>> mostrar este asistente".
>>> */
>>> JSObject checkboxClickedCallback = (JSObject)
>>> javascriptContext.get("{}");
>>> checkboxClickedCallback.set("setChecked", new JSFunction() {
>>> public void apply(JSObject self, Object[] args) {
>>> Log.p("->checkboxClickedCallback.setChecked()");
>>> contexto.mostrarMensaje("checkboxClickedCallback.setChecked()");
>>>
>>> }
>>> });
>>> javascriptContext.set("window.checkboxClickedCallback",
>>> checkboxClickedCallback);
>>>
>>> /*
>>> * Registramos el callback JS de click en el botón "OK".
>>> */
>>> JSObject okButtonClickedCallback = (JSObject)
>>> javascriptContext.get("{}");
>>> okButtonClickedCallback.set("showMap", new JSFunction() {
>>> public void apply(JSObject self, Object[] args) {
>>> Log.p("->okButtonClickedCallback.showMap()");
>>> contexto.mostrarMensaje("okButtonClickedCallback.showMap()");
>>>
>>> }
>>> });
>>> javascriptContext.set("window.okButtonClickedCallback",
>>> okButtonClickedCallback);
>>>
>>>     Please help, as it's impacting our current production code.
>>>
>>> Kind regards,
>>>      Kandy
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "CodenameOne Discussions" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to codenameone-discussions+unsubscr...@googlegroups.com.
>>> Visit this group at https://groups.google.com/grou
>>> p/codenameone-discussions.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/codenameone-discussions/493a9217-0a4a-44b5-aede-974096f6
>>> 52d4%40googlegroups.com
>>> <https://groups.google.com/d/msgid/codenameone-discussions/493a9217-0a4a-44b5-aede-974096f652d4%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Steve Hannah
>> Software Developer
>> Codename One
>> http://www.codenameone.com
>>
> --
> You received this message because you are subscribed to the Google Groups
> "CodenameOne Discussions" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to codenameone-discussions+unsubscr...@googlegroups.com.
> Visit this group at https://groups.google.com/
> group/codenameone-discussions.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/codenameone-discussions/0aa6820b-d038-4a3f-82ad-
> c45fb4c6d5e6%40googlegroups.com
> <https://groups.google.com/d/msgid/codenameone-discussions/0aa6820b-d038-4a3f-82ad-c45fb4c6d5e6%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Steve Hannah
Software Developer
Codename One
http://www.codenameone.com

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to codenameone-discussions+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/CAGOYrKV7J%2BGoMb5qbh16gp6s8-JCP3UoQNsUwz5NPtvcATNbSA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to