View Full Version : accessing the http request that initialized the LZX
tangollama
03-04-2003, 05:36 AM
Is there a way to get access to the http request variables that call a compiled laszlo executable through a dataset or something. I'm having trouble finding it and hoping I'm just being dense. I see the dataset I can generate from a further http request but I wondered if the initial calling request was available, perhaps an xml doc is created and fed to the presentation implicitly, etc.
Can you explain what your are trying to do a little more clearly? I am not sure I understand the question.
metasarah
03-04-2003, 06:44 AM
You can specifiy cgi parameters that end up being accessible by your script as global vars.
If you call the enclosed lzx like this...
http://localhost:8080/lps-dr/param_test.lzx?debug=true&foo=4
Then foo is defined as a global variable -- which can be accessed wherever (my sample shows it used in a <script> tag and an onclick handler)
debug=true was a good hint :)
By the way, in your code for param_test.lzx, you can replace this line
<text ondata="this.setWidth(this.getTextWidth())" datapath="@title" fgcolor="blue"></text>
<text resize="true" datapath="@title" bgcolor="blue"></text>
the "resize" attribute tells text to automatically resize it's width when it's setText() method is called (this only applied to single-line text, not multiline=true text areas)
Oops, after trying it, resize="true" does not seem to work on your example. I think that may be a bug with how text is initialized from datapaths, I will check.
The following code works for me, in the development world anyway, and each text field is automatically sized to the text it contains. You can tell because when the text is highlighted, the blue color extends exactly to the end of the text. So using resize="true" on a text view does work equivalently to the "setTextWidth(getTextWidth())" event handler
script.
<canvas>
<dataset name="mydata" >
<myXML>
<book title="The Psychology of Everyday Things"/>
<book title="Understanding Media"/>
<book title="Mind in Society"/>
</myXML>
</dataset>
<view name="root" >
<simplelayout/>
<text>some books i like</text>
<view name="itemList" datapath="mydata:/myXML/book"
onmouseover="this.setBgcolor(0xEEEEFF)"
onmouseout="this.setBgColor(0xFFFFFF)" >
<text resize="true" datapath="@title" fgcolor="blue"></text>
<method name="openItem" event="onclick">
Debug.Write("foo ="+foo);
</method>
</view>
</view>
</canvas>
tangollama
03-06-2003, 06:57 AM
So, I'm still having trouble with the very simple concept of CGI variables, as well as some of the other finer points to the language.
#1 the CGI variables
Here's the code in my web page:
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"
WIDTH="100" HEIGHT="800" >
<PARAM NAME="movie" VALUE="<ui:jspUrl/>/templates/jworrall/menubar.lzx?lzt=swf&bgColor=<style:stylePreference name="<%=StylePreferenceKeys.BODY_BACKGROUND_COLOR%>"/>" />
<PARAM NAME="quality" VALUE="high" />
<PARAM NAME="scale" VALUE="exactfit" />
<PARAM NAME="salign" VALUE="lt"/>
<EMBED src="<ui:jspUrl/>/templates/jworrall/menubar.lzx?lzt=swf&bgColor=<style:stylePreference name="<%=StylePreferenceKeys.BODY_BACKGROUND_COLOR%>"/>" quality="high" scale="exactfit" salign="lt"
WIDTH="100" HEIGHT="800" TYPE="application/x-shockwave-flash"
PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" />
</OBJECT>
The JSP tag (style:stylePreference) returns a 6 character value for the RGB color (if you look @ the rendered html, it looks like this):
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"
WIDTH="100" HEIGHT="800" >
<PARAM NAME="movie" VALUE="http://jworrall.mars.dev.commnav.com:8014/mars/templates/jworrall/menubar.lzx?lzt=swf&bgColor=d5681f" />
<PARAM NAME="quality" VALUE="high" />
<PARAM NAME="scale" VALUE="exactfit" />
<PARAM NAME="salign" VALUE="lt"/>
<EMBED src="http://jworrall.mars.dev.commnav.com:8014/mars/templates/jworrall/menubar.lzx?lzt=swf&bgColor=d5681f" quality="high" scale="exactfit" salign="lt"
WIDTH="100" HEIGHT="800" TYPE="application/x-shockwave-flash"
PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" />
</OBJECT>
But the debug output of Debug.write('bgColor='+bgColor); doesn't print the value passed into the script.
#2 When are script tags executed?
It makes sense to me that script tags would just be executed when the particular view was initialized but perhaps not.
#3 How do I change a view's resource?
I have script code to set a view's resource in its init event to the value of the run-time based icon image but it never seems to take. Here's my basic code structure:
<resource src="icon.jpg" name="icon_resource" />
<class name="xyz" >
<view name="top">
<view name="icon" />
</view>
<method name="doinit" args="title,iconVal,openedHeightTotal" >
if (iconVal) {
this.top.icon.setResource(iconVal);
}
</method>
</class>
<xyz oninit="doinit('Something', icon_resource, 45)" />
This code (roughly) doesn't actually use the icon I specify.
mdavis
03-13-2003, 02:28 PM
#1 the CGI variables...
I have a script that does exactly what you are trying to do with the bgColor. The first thing to try is changing the name of that variable to something else.
...?lzt=swf&t0bgc=0x00ee00...
bgColor from the query string will be overridden by the canvas bgcolor on intit of the app. That is true of all globals for your app.
#2 <script> is executed first. IIRC before instatiation of views.
#3 is a bit trickier...
Check and doublecheck your quoting. Here is a sample that does what you are wanting:
<canvas debug="true" width="1024">
<resource name="A" src="cards/2c.gif"/>
<resource name="B" src="cards/3c.gif"/>
<resource name="C" src="cards/4c.gif"/>
<class name="foo">
<view name="goo" bgcolor="red" width="30" height="30">
<view name="goo2" bgcolor="green" width="20" height="20"/>
</view>
<method name="doinit" args="mfoo,res">
if (mfoo){
goo.goo2.setResource(res);
debug.write('hah');
}
</method>
</class>
<foo name="foo2" oninit="doinit(1,'B')"/>
</canvas>
Try that
antun
03-13-2003, 02:45 PM
CGI variables should be accessible as globals as follows:-
<canvas debug="true">
<script>
debug.write( smelly );
</script>
</canvas>
Using the querystring:-
http://localhost:8080/lps-dr/my-apps/tangollama/cgivars.lzx?smelly=bad
Does this not work for you?
-Antun
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.