Howdy again, Here's the description of the third and (I hope) final part of my on going effort to turn mozilla into an effective stand- alone database client. The outliner widget is a very effective and relatively efficient mechanism for displaying "computed" data. It also lends itself very handily to displaying tabular data straight from a database. All that is needed by the outliner widget is to provide an implementation of the nsIOutlinerView interface. I've done just that for the mySQL database engine. It's a tiny DLL (53 kilobytes for the DEBUG version). I'm also planning an ODBC version. I'll post the code (consider it LGPL'd) for the mySQL version as an attachment momentarily. Here's what a sample outliner XUL file looks like: <?xml version="1.0"?> <?xml-stylesheet href="chrome://navigator/skin/navigator.css" type="text/css"?> <!DOCTYPE window> <window xmlns:html="http://www.w3.org/1999/xhtml" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" align="vertical" onload="prep();" onclose="mySQL.close();"> <script language="JavaScript"> var mySQL = {}; function prep() { mySQL = Components.classes["@mozilla.org/mySQL/Outliner;1"].createInstance(); mySQL = mySQL.QueryInterface(Components.interfaces.mozIDataBase); if ( mySQL.open("test", "", "") ) { alert("Set BP now!"); var outliner = document.getElementById('ex-outliner'); outliner.outlinerBoxObject.view = mySQL.getView("SELECT * FROM sample"); } } </script> <outliner id="ex-outliner" flex="1"> <outlinercol id="id" label="ID" flex="1" crop="left"/> <outlinercol id="name" label="Name" flex="2" crop="left"/> <outlinercol id="address" label="Address" flex="2" crop="left"/> <outlinercol id="city" label="City" flex="2" crop="left"/> <outlinercol id="state" label="State" flex="1" crop="left"/> <outlinercol id="postal" label="Postal" flex="1" crop="left"/> <outlinerbody flex="1"/> </outliner> </window> To make this work, I had to do the following: 1. have mySQL installed and running on my system 2. create a "sample" table in the test database on mySQL like so: mySQL> use test; mySQL> create table sample mySQL> (id integer not null, mySQL> name varchar(24), mySQL> address varchar(24), mySQL> city varchar(16), mySQL> state varchar(16), mySQL> postal varchar(10), mySQL> primary key(id) ); mySQL> insert into sample values(1, "Joe Cool", mySQL> "101 Main Street", "Houston", "Texas", "77002"); mySQL> insert into sample values(2, "Ben Stein", mySQL> "101 Lincoln Lane", "Houston", "Texas", "77025"); mySQL> insert into sample values(3, "Ali Gator", mySQL> "101 Swamp Road", "Houston", "Texas", "77005"); 3. install the above XUL file as a chrome package in mozilla. 4. copy the XPCOM component files (DLL and XPT) to the dist/bin/components folder and register them. 5. run mozilla from a shell prompt using the chrome switch: > mozilla -chrome chrome://dboutliner/content My ultimate goal is to produce a component that will serve all three - provide RDF datasourcing for XUL templates, handle populating a XUL dialog, and act as a view for an outliner widget. The penalty for using such a component shouldn't be more that a dozen lines of JavaScript in your XUL chrome files. A few caveats are in order: all contract IDs, interface IDs, and interfaces are certain to change. Example: the badly named "mozIDataBase" interface uses |char*| instead of |PRUnichar*| for passing strings - I'll fix that at some point. The makefile.in file is dubious at best as I haven't even tried this on Linux yet. Regards, Rick Parrish [EMAIL PROTECTED] (code to follow)
