[Laszlo-dev] For Review: Change 20090109-maxcarlson-i Summary: Provide a callMethod API on the html component to call JavaScript methods in the iframe

André Bargull andre.bargull at udo.edu
Fri Jan 9 10:23:00 PST 2009


Apart from the name, I'd also like to have a similar function signature, 
so it's easier for users to cope with both functions.
The current signature for lz.Browser.callJS is:
> function callJS (methodname:String, callback:Function = null, args:* = null) :void;

Note: "args" is actually a ...rest argument, so you call a js-function 
with `lz.Browser.callJS("func", null, 1, 2, 3, 4)` where `1, 2, 3, 4` 
are the arguments for the js-function. You don't use 
`lz.Browser.callJS("func", null, [1, 2, 3, 4])`, that'd mean you call 
the js-function with an array of `[1, 2, 3, 4]`. (I don't know why AS3 
doesn't choke at runtime when you call it with 
`lz.Browser.callJS("func", null, 1, 2, 3, 4)`, it just works...)

So it should be at least:
> <method name="callMethod" args="methodName, scope = null, callbackDel = null, ...args">

Next thing which comes to my mind: why does lz.Browser.callJS doesn't 
accept a delegate? I think it should, so you don't need to wrap the 
callback-execution in a function.

And I think the scope in which the js-function is called, should always 
be the global-object. That way it's more compliant to lz.Browser.callJS 
(and honestly it doesn't make sense to me to over-feature a less used 
function in comparison to lz.Browser.callJS).

So the signature should be exactly like lz.Browser.callJS:
> <method name="callMethod" args="methodName, callbackDel = null, ...args">


And there is a bug in "callMethod" in "iframemanager.js"
> +            var retVal = iframe[scope][methodName].apply(iframe, args);

The function is already just called within the global scope.


On 1/9/2009 3:25 PM, P T Withington wrote:
> 'callMethod' seems like the wrong name.  Isn't this really calling a 
> Javascript function, and doesn't it more closely parallel 
> lz.Browser.callJS?  So maybe it should have the same name?  Maybe the 
> name of both of those should be `callJavascript` instead of `callJS`, so 
> they are more obvious?
> 
> On 2009-01-09, at 08:54EST, Max Carlson wrote:
> 
>> Change 20090109-maxcarlson-i by maxcarlson at Bank.lan on 2009-01-09 
>> 04:58:45 PST
>>    in /Users/maxcarlson/openlaszlo/trunk-clean
>>    for http://svn.openlaszlo.org/openlaszlo/trunk
>>
>> Summary: Provide a callMethod API on the html component to call 
>> JavaScript methods in the iframe
>>
>> Bugs Fixed: LPP-7595 - Provide a callMethod API on the html component 
>> to call JavaScript methods in the iframe
>>
>> Technical Reviewer: lhenrywilkins at laszlosystems.com
>> QA Reviewer: andre.bargull at udo.edu
>> Doc Reviewer: liorio
>>
>> Details: html.lzx - Add callMethod() and document it, and scrollTo().
>>
>> iframemanager.js - Add implementation of callMethod().
>>
>> test/html.lzx - Add tests for scrollTo() and callMethod()
>>
>> test/html-callmethod.lzx - Testcase for html method callbacks
>>
>> test/html-test.html - HTML page loaded by html.lzx and 
>> html-callMethod.lzx
>>
>>
>> Tests: test-callmethod.lzx runs consistently across all runtimes.
>>
>> Files:
>> M      lps/components/extensions/test/html.lzx
>> A      lps/components/extensions/test/html-test.html
>> A      lps/components/extensions/test/html-callmethod.lzx
>> M      lps/components/extensions/html.lzx
>> M      lps/includes/source/iframemanager.js
>>
>> Changeset: 
>> http://svn.openlaszlo.org/openlaszlo/patches/20090109-maxcarlson-i.tar
> 
> 



More information about the Laszlo-dev mailing list