I have talked a bit about the new built-in datasources (XML and SQL) developers can use with XUL templating (guide and tutorial). I wanted to wrapup my little foray into XUL template datasources by also talking about custom datasources.
A generic framework for adding any kind of datasource (bug 321170) was created as part of the work to make the new XML and SQL datasources. Creating a custom datasource involves implementing 2 new XPCOM interfaces: nsIXULTemplateQueryProcessor and nsIXULTemplateResult.
With the help of Peter van Hardenberg (of Songbird), I got a simple JavaScript implementation working and available on MDC. The sample is fairly basic, but you could extend it to expose any kind of backend datasource.
Do you have a working example available online for the Javascript demo?
Didn’t see one on this page.
Scott – I use the sample in XUL Explorer. Just copy the JS to a file in the “components” folder and paste the XUL in a new XUL Explorer document tab. Previewing should work. Worse case, you might need to delete your XUL Explorer profile folder to get the component registered.
To make it work with Firefox 3 (and in general), you would need to make an extension to install the JS component.
Thanks I’ll try that. XUL Explorer is nice.
Hi Mark, thanks a ton for the writeups on the template/datasource changes. I spent years trying to write an RDF-heavy CMS-addon using Mozilla. RDF was the craggy rock my effort sank on. [wink]
I spent around 3 hours last night trying to apply what I remembered about template datasources to the new model. While it is easy to get a datasource registered and template content generated, I quickly got lost on scripting it: attaching datasources dynamically, modifying the “model” and seeing template updates (hopefully without .reload()), reloading the model and seeing new content.
Do you have any recommended place to explore how I can do read-write data with the new datasources?
Paul – looks like we could get the functionality. See http://groups.google.com/group/mozilla.dev.platform/browse_frm/thread/859ab3318cfec356#09f079f250712a5c
Thanks Mark for entering that bug id. I’m wondering if it is premature for me to tackle such an app (e.g. a little XULRunner database with read/write forms.) I’ll give it some more effort though.