A question about rebuild the tree after refresh the rdf datasource!

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

A question about rebuild the tree after refresh the rdf datasource!

benkwan-2
When i use rdf datasources property of tree, a strange question about
rebuilding the tree comes out. I set the datasources property of tree
with a uri of a rdf file(just like chrome://test/content/test.rdf).
this rdf file can be modified in other codes. When the rdf file is
changed(add or remove resources),i run these code:
/////////////////////////////////////
var RDF = Components.classes["@mozilla.org/rdf/rdf-service;1"]
                      .getService
(Components.interfaces.nsIRDFService);
  var ds = RDF.GetDataSource("chrome://test/content/test.rdf");
  ds.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource);
  ds.Refresh(false);
/////////////////////////////////////

When the change is removing some resources from the rdf file, the tree
rebuild itself after refreshing datasource.But if the change is adding
some resources to the rdf file,the tree does nothing after refreshing
datasource. I have to run these code to rebuild the tree manually:

/////////////////////////////////////
var tree = document.getElementById("root-tree");
tree.rebuild();
/////////////////////////////////////

why the tree doesn't rebuild itself in the second condition!
_______________________________________________
dev-tech-rdf mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-rdf
Reply | Threaded
Open this post in threaded view
|

Re: A question about rebuild the tree after refresh the rdf datasource!

Neil Deakin
BenKwan wrote:
> why the tree doesn't rebuild itself in the second condition!

Hard to tell without seeing what is being changed. If the new data
doesn't relate to what's already in the tree, nothing will happen.

Note that changing the datasource never rebuilds the template. It only
updates the pieces that would need changing.
_______________________________________________
dev-tech-rdf mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-rdf
Reply | Threaded
Open this post in threaded view
|

Re: A question about rebuild the tree after refresh the rdf datasource!

benkwan-2
On Jun 26, 7:19 pm, Neil Deakin <[hidden email]> wrote:
> BenKwan wrote:
> > why the tree doesn't rebuild itself in the second condition!
>
> Hard to tell without seeing what is being changed. If the new data
> doesn't relate to what's already in the tree, nothing will happen.
>
> Note that changing the datasource never rebuilds the template. It only
> updates the pieces that would need changing.

My RDF file is :
<?xml version="1.0"?>
<RDF:RDF xmlns:NS1="http://netDisck.desktopx.org/rdf#"
         xmlns:NC="http://home.netscape.com/NC-rdf#"
         xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">

  <RDF:Seq RDF:about="http://netDisck.desktopx.org/rdf#LogicalRoot">
    <RDF:li RDF:resource="http://netDisck.desktopx.org/rdf#ll"/>
    <RDF:li RDF:resource="http://netDisck.desktopx.org/rdf#22"/>
    <RDF:li RDF:resource="http://netDisck.desktopx.org/rdf#33"/>
    <RDF:li RDF:resource="http://netDisck.desktopx.org/rdf#44"/>
    <RDF:li RDF:resource="http://netDisck.desktopx.org/rdf#55"/>
  </RDF:Seq>
  <RDF:Description RDF:about="http://netDisck.desktopx.org/
rdf#LogicalRoot"
                   NS1:path="/alfresco/webdav/Users/126162/Files/"
                   NS1:id="/alfresco/webdav/Users/126162/Files/"
                   NS1:name="root"
                   NS1:parent=""/>
  <RDF:Description RDF:about="http://netDisck.desktopx.org/rdf#ll"
                   NS1:path="/alfresco/webdav/Users/126162/Files/ll/"
                   NS1:id="/alfresco/webdav/Users/126162/Files/ll/"
                   NS1:name="ll"
                   NS1:parent="" />
  <RDF:Description RDF:about="http://netDisck.desktopx.org/rdf#22"
                   NS1:path="/alfresco/webdav/Users/126162/Files/ll/"
                   NS1:id="/alfresco/webdav/Users/126162/Files/ll/"
                   NS1:name="22"
                   NS1:parent="" />
  <RDF:Description RDF:about="http://netDisck.desktopx.org/rdf#33"
                   NS1:path="/alfresco/webdav/Users/126162/Files/ll/"
                   NS1:id="/alfresco/webdav/Users/126162/Files/ll/"
                   NS1:name="33"
                   NS1:parent="" />
  <RDF:Description RDF:about="http://netDisck.desktopx.org/rdf#44"
                   NS1:path="/alfresco/webdav/Users/126162/Files/ll/"
                   NS1:id="/alfresco/webdav/Users/126162/Files/ll/"
                   NS1:name="44"
                   NS1:parent="" />
  <RDF:Description RDF:about="http://netDisck.desktopx.org/rdf#55"
                   NS1:path="/alfresco/webdav/Users/126162/Files/ll/"
                   NS1:id="/alfresco/webdav/Users/126162/Files/ll/"
                   NS1:name="55"
                   NS1:parent="" />
</RDF:RDF>

my tree:
<tree id="root-tree" flex="1"  context="clipmenu"
datasources="netDisckSource.rdf"  ref="http://netDisck.desktopx.org/
rdf#root" >

when i delete <RDF:li RDF:resource="http://netDisck.desktopx.org/
rdf#55"/> and <RDF:Description RDF:about="http://netDisck.desktopx.org/
rdf#55" from the rdf file.my refresh js code is :
function refresh()
{
var RDF = Components.classes["@mozilla.org/rdf/rdf-service;
1"].getService(Components.interfaces.nsIRDFService);
var ds = RDF.GetDataSource("chrome://treeroot/content/
netDisckSource.rdf");
ds.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource);
ds.Refresh(false);
}

the tree displays all right.the node "55" is remove, and now i add
<RDF:li RDF:resource="http://netDisck.desktopx.org/rdf#66"/> and
<RDF:Description RDF:about="http://netDisck.desktopx.org/rdf#66" to
the rdf file and invoke refresh(),nothing is changed. But if add this
to the end of the refresh() function:
"var tree = document.getElementById("root-tree");
  tree.builder.rebuild();"
the tree display all right,too!

This is the situation i meet.
_______________________________________________
dev-tech-rdf mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-rdf