[Laszlo-user] Dynamically adding views with resources from a dataset

Philip A. Chapman pchapman at pcsw.us
Fri Dec 21 08:13:32 PST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Guys,

I'm trying to create a dialog which will request a list of images from
the server.  The XML returns a list with a bunch of URLs.  I'm trying to
use the URLs to build a list of thumbnails in the dialog.  However, the
thumbnails I create don't show up on the dialog.  I know that the images
are not being requested.  Any help would be great:


<library>

	<class name="bgpot" height="58" width="66">
		<attribute name="bgid" type="number" value="0"/>
		<attribute name="iconpath"/>
		<attribute name="imagepath"/>
		<attribute name="listener" type="expression"/>
		<method event="onclick">
			listener.changeBackground(this.getAttribute('bgid'),
this.getAttribute('imagepath'));
		</method>
		<view bgcolor="#444444" height="56" width="64">
			<image name="bgicon" resource="${parent.iconpath}" height="54"
width="64"/>
		</view>
	</class>

	<class
		name="BackgroundChooser" extends="modaldialog" width="322" height="245"
		bgcolor="#10F60A" visible="false"
	>
		<attribute name="selectedBackground" type="number" value="0"/>

		<method name="changeBackground" args="c">
			<![CDATA[
				this.setAttribute('selectedBackground', c);
				this.close();
			]]>
		</method>
		
		<view x="-333" y="0" height="245" width="322" visible="false"
name="bgdisplay">
			<wrappinglayout axis="x" spacing="5"/>
		</view>
		
		<dataset
			name="backgroundsRequest" querytype="post" type="http"
onerror="classroot.loadError()"
			src="../datatransfer" ondata="classroot.loadSuccess()"
		/>
		<method name="open"><![CDATA[
			Debug.write("Requesting backgrounds...");
			
			var ds = backgroundsRequest;
			var p = new LzParam();
			p.addValue("sessionid", canvas.drawingStatus.sessionid, true);
			p.addValue("requesttype", "GetBackgrounds", true);
			ds.setQueryString(p);
			ds.doRequest();
			super.open();
		]]></method>
		<method name="loadError"><![CDATA[
			Debug.write('Backgrounds load error');
			Debug.write('Response data: ' + backgroundsRequest.serialize());
		]]></method>
		<method name="loadSuccess">
			var node =
backgroundsRequest.getElementsByTagName("response")[0].getElementsByTagName("code")[0].childNodes[0];
			if (node.data == "100") {
				var nodes =
backgroundsRequest.getElementsByTagName("response")[0].getElementsByTagName("imageList")[0].childNodes;
				Debug.inspect(this.bgdisplay);
				for (n in nodes) {
					var bg = new bgpot(this.bgdisplay);
					bg.bgid = nodes[n].getElementsByTagName("id")[0].childNodes[0].data;
					bg.iconpath =
nodes[n].getElementsByTagName("iconpath")[0].childNodes[0].data;
					bg.imagepath =
nodes[n].getElementsByTagName("path")[0].childNodes[0].data;
					this.bgdisplay.addSubview(bg);
				}
				Debug.write('Backgrounds Loaded successful');
			} else {
				Debug.write('Backgrounds load failed');
				Debug.write('Response data: ' + backgroundsRequest.serialize());
			}
		</method>
	</class>
</library>



Thanks,
- --
Philip A. Chapman

Desktop and Web Application Development:
Java, .NET, PostgreSQL, MySQL, MSSQL
Linux, Windows 2000, Windows XP

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHa+YsAdpynRSGw3URAtxHAJ93G/KHxVWgb4roV+CJcipWICsUqQCdF5JY
WR8+KWmPJQZRexBHg4vHKQw=
=1YRl
-----END PGP SIGNATURE-----


More information about the Laszlo-user mailing list