Re: sharing RDF datasource between iframes or through reload

Axel Hecht <[email protected]> Fri, 01 Apr 2005 16:01:48 +0200
Newsgroups gmane.comp.mozilla.devel.rdf
Organization Another Netscape Collabra Server User
Message-ID <[email protected]>
vaab wrote:
> Hi,
> 
> I have a problem using RDF through an application made with different 
> iframe. Basically, the best-fit datasource type for our data is the 
> in-memory-datasource style. But iframes reloads their javascript, so the 
> in-mem statement for declaring the javascript variable holding the RDF 
> datasource catches a new RDF in-mem Datasource (an hole new one, so it 
> is empty) each time we switch iframes... This forbids us to share the 
> datasource between iframes...
> 
> When developping another application, I've come along with strange RDF 
> Datasource problems that involved strange artifact stored in my RDF 
> datasources and that could not be removed by a simple reload of the 
> script. They disappeared only after a complete shutdown of firefox, and 
> reload.
> 
> This leads me to think that there's a way to store in-mem informations 
> that could be transmitted through reload or iframes... Have you some 
> hints to share ?


This sounds like you're using a classical frames approach for web apps 
to do a XUL (or at least chrome://) app. Have you thought about going 
for a <xul:stack> instead?

Apart from that, RDF datasources retrieved through the RDF service are 
cached as long as someone holds a reference to it. This is sometimes a 
bit odd when it comes down to caching and reloading and such. This is 
what you saw.
You can keep a reference to your inmem ds in the parent of the iframe, 
and expose that via parent.mDS if you have a window.mDS in the parent. 
That should work, but don't forget to delete the member as soon as you 
don't need it anymore, otherwise you leak.

Relying on some odd caching artifact and the js garbage collection to 
not pick up your ds from one frame to the next by faking a global 
datasource sounds weak and brittle. You could of course do that via a js 
component, which would just need to pick the right contract id and 
create in-mem datasources for that. But it's not supposed to work, as we 
shouldn't leak datasources forever (which is what you assume we do). You 
could get to that datasource via a rdf:x-foo/blah datasource, pick 
something rather unique.

Axel