Template and automatic UI update from datasource

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Template and automatic UI update from datasource

Michel Gutierrez-2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


hi all,

i'm stuck with a problem using templates and dynamic datasources.
in my extension, i use templates extensively, feeding them with in-memory datasources controlled by my background code.
i'm using this code to attach the datasource to xul elements:

UtilService.prototype.setDatasource=function(tree,ds) {
        this.removeDatasources(tree);
        if(ds!=null)
                tree.builder.database.AddDataSource(ds);
        tree.builder.rebuild();
}

UtilService.prototype.removeDatasources=function(tree) {
        var dss=[];
        var i=tree.builder.database.GetDataSources();
        while(i.hasMoreElements()) {
                dss.push(i.getNext());
        }
        for(var i=0;i<dss.length;i++) {
                var ds = dss[i].QueryInterface(Components.interfaces.nsIRDFDataSource);
                tree.builder.database.RemoveDataSource(ds);
        }
}

this works just fine the first time i call setDatasource with a fresh ds, the user interface is automatically updated when changes are
made to the datasource.
then i call again setDatasource with another datasource. the mapping to the new datasource works but when changes are made in this
datasource, they are not reflected in the UI. i have to call builder.rebuild() manually.
does anyone have a clue about this ?

/mig



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

iD8DBQFFtNZ7tMkIv0/ruZgRAulDAJ9GUkOBEJuLAtOK1FnzRvxCJ7wb+gCfS284
D2lLampkL7OzrcZzBPGWMOM=
=MgKo
-----END PGP SIGNATURE-----
_______________________________________________
dev-tech-rdf mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-rdf
Reply | Threaded
Open this post in threaded view
|

Re: Template and automatic UI update from datasource

mixit
Yes, you do need to call builder.rebuild() to update the UI when
adding datasources like this.
I do exactly the same thing but on a larger scale and ran into the
same issue - there do seem to be a few inconsistencies though
so I can appreciate your frustration.
Its just safer to always assume you have to call rebuild().

_______________________________________________
dev-tech-rdf mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-rdf