Magazine
 
Quick Review:Ajax
 
Ajax and XML: Five cool Ajax widgets

I start the show off with the SWF/Charts widget, because I think it’s one of the easiest widgets to deploy. It also provides the biggest return for the effort.

The SWF/Charts widget
It’s hard to argue with the old saying, “A picture is worth a thousand words,” particularly where graphs are concerned. But graphing on the Web has always been a problem. Most Web frameworks lack a graphing tool right out of the box, although some include the graphics primitives for building images. This lack of functionality leaves you stuck building graphs on your own. Wouldn’t it be great if there were a widget that would just graph XML-encoded data? Turns out, there is one: SWF/Charts. To start using this widget, I download the SWF file from the site along
with the extra SWF files that the widget uses. Then, I installed the files on my site and added a link to the SWF widget on the HTML page, as shown in Listing 1.

Listing 1. Chart_page.html

<html><body>
<object
classid=”clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase=”http://download.macromedia.com/pub.../swflash.cab#version=6,0,0,0"
width=”400" height=”250">
<param name=”movie”
value=”charts.swf?xml_source=chart_data.xml&library_path=charts_library”>
<embed
src=”charts.swf?xml_source=chart_data.xml&library_path=charts_library”
width=”400" height=”250"
type=”application/x-shockwave-flash”
pluginspace=”http://www.macromedia.com/go/getflashplayer”>
</embed>
</object>
</body></html>

Charts.swf takes two parameters: the location of its libraries directory and the URL of the XML data. The XML data format is ridiculously easy. Listing 2 shows a simple example.

Listing 2. Chart_data.xml

<chart>
<chart_type>bar</chart_type>
<chart_data>
<row>
<null/>
<string>2005</string>

Apr 2008 | Java Jazz Up | 48
 
previous
index
next
 
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,

30
, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 , 54, 55, 56, 57,

58
, 59, 60, 61, 62, 63 , 64, 65 , 66 , 67 , 68 , 69 , 70, 71, 72, 73, 74, 75, 76, 77, 78,   Download PDF