PDA

View Full Version : Communicate between html-laszlo


Tanmay
08-27-2009, 03:01 AM
I am showing a html page using <html> tag inside a window in Open Laszlo. I want to pass some value from laszlo side to a text control inside the html and vice-versa. How am I going to acheive this..?

Below is the code snippet..
<class name="browser" title="SPELL CHECKER" extends="window" resizable="true" width="420" height="400" visible="false" closeable="true">
<attribute name="textValue" type="string" value=""/>
<view height="100%" width="100%">
<simplelayout spacing="1" axis="y" />
<html name="htmlview" width="400" height="320" visible="true"/>
<button align="center">Ok</button>
</view>
</class>

<browser id="winspellcheck" width="420" height="400" name="objbrowser">
<handler name="onvisible">
if(this.visible)
{
this.searchSubnodes("name","htmlview").setAttribute("src","http:testspell.html");
//this.searchSubnodes("name","htmlview").setAttribute("wmode","transparent");
this.searchSubnodes("name","htmlview").bringToFront();

}
</handler>
</browser>

<view width="100%" height="100%">
<edittext height="200" width="300" multiline="true" name = "spellchk" text="123">
<handler name="onfocus">
winspellcheck.textValue = this.text;
canvas.searchSubnodes('id','winspellcheck').open() ;
</handler>
</edittext>
</view>

stupiduser
08-27-2009, 11:16 AM
you could pass the parameter in the html src tag
example
<html id="hta" src="http://www.google.co.id/search?q=passing" width="${parent.width - 30}" height="${parent.height - 30}"/>
but this will make you refresh the page

there is also a method "callJavascript()" in the "view basics->html" reference docs but i never tried it

you could also use ajax ( lazlo <-> php/jsp/asp <-> html/javascript )

hope my post could be a help for you

Tanmay
08-27-2009, 09:57 PM
Thanks for the input, yes yesterday I achieved the thing you mentioned here i.e. sending the parameters from calling Laszlo to <html> by using the querystring only. But aftre this I had hit a dead end :( . I want to pass back some params from <html> to laszlo. Say I have a textarea inside <html> and I have a button (laszlo one) in a window. Now on click of the button I want the content of html textarea to be passed back to laszlo and the window closes.
My issue is I am not able to access the textarea inside the html from laszlo. Tried posting also so that the URL changes and I capture the URL querystring for params, but strangely though the html posts data, when trying to acess the src attribute of it on laszlo it still is the original one...

So still trying on it...
Greatly Appreciate Any Bright Idea / Help / Advice on this...

Tanmay
08-27-2009, 10:52 PM
Yoohooo..got it, :D .. I used the callJavascript method of <html> to get back the data from html to laszlo..
Below is the code...

Laszlo Side ..
Use any event handler for below, I used Button click

<button align="center">Ok
<handler name="onclick">
var del = new LzDelegate(this,'returnval');
canvas.searchSubnodes("name","htmlview").callJavascript('ReturnText', del);
canvas.searchSubnodes('id','winspellcheck').close( );
</handler>
<method name="returnval" args="retVal">
canvas.searchSubnodes('name','spellchk').setAttrib ute('text',retVal);
</method>
</button>

"htmlview" is the html control on laszlo page here..
On Html side I had a function 'ReturnText' which returns the value in textarea --

<script type="Text/Javascript">
function ReturnText(){
var myText=MyForm.htmlCode.value;
return myText;
}
</script>

"htmlCode" above is the id of the <textarea>.

:cool::):cool::D

Though my problem is solved, I will really appreciate if anyone posts other approaches for this..