PDA

View Full Version : Views not refreshing when the datapath is changed


k-billy
10-30-2003, 09:23 AM
Hi,

I'm having a problem refreshing a view when the datapath it uses is changed.

I am using the datapath.setFromPointer() method to reset
the datapath each time on a class. The subviews/widgets of this class all have their 'ondata' methods called when I change the class' datapath. I am printing the widget's datapath when the ondata event is fired, and the datapath has been updated correctly. But the view itself is not updating. In fact, in some cases, it completely dissapears.

I have a couple of questions:

1. Is there a known bug with regards to a View refreshing when its datapath (or its parent view's datapath) is changed at runtime? If there is a bug, is there an accepatable workaround?

2. If there isn't a bug, Is there a correct way to dynamically modify a datapath object and have the view refresh? I have tried numerous approaches with inconsistent (and unsatisfactory) results:

-calling view.datapath.setXPath()
-calling view.setDatapath()
-calling view.datapath.setFromPointer(updatedDatapointer)
-manipulating the actual dataset, by removing the
original node that the view is pointing too, and inserting a new node.

Any input is greatly appreciated.

Caleb

antun
10-30-2003, 10:01 AM
Hi Caleb

You're right - there is actually a bug filed against this, and it will be fixed in the next release. It's only caused by setFromPointer(), not by setDatapath().

I would always use setDatapath(). I believe that view.datapath.setXPath() and view.setDatapath() are the same. Just be aware that if you set a datapath at runtime using setDatapath(), you have to pass it an absolute XPath for the time being. This too should be fixed in the next release.

-Antun

k-billy
10-30-2003, 10:20 AM
Hi Antun,

thanks for the quick response! I have a few follow up questions:

1. Does an absolute XPath need to include the dataset name? For example:
"myDataset:/something[1]/childSomething"

or can it just be:
"/something[1]/childSomething"

2. I have also called setDatapath() and passed a LzDatapath
object as the parameter. Is this also an acceptable approach?

3. I am assuming that child subviews will also refresh when the parent views datapath is reset. Is this acurate?

antun
10-30-2003, 10:47 AM
Does an absolute XPath need to include the dataset name?

I think so - I just did a quick test, and it looks like it does need to include the name:


<canvas debug="true">
<dataset name="myds">
<myroot>
<mynode name="foo">
<mysecondnode name="bar" />
</mynode>
</myroot>
</dataset>


<simplelayout axis="y" spacing="20" />

<text name="smelly" width="100" datapath="myds:/myroot/mynode/@name" />

<button>With dataset name
<method event="onclick">
var dp = "myds:/myroot/mynode/mysecondnode/@name";
smelly.setDatapath( dp );
</method>
</button>

<button>Without dataset name
<method event="onclick">
var dp = "/myroot/mynode/mysecondnode/@name";
smelly.setDatapath( dp );
</method>
</button>
</canvas>


I have also called setDatapath() and passed a LzDatapath object as the parameter. Is this also an acceptable approach?

Did this work? setDatapath() needs to take a string which is an XPath.


I am assuming that child subviews will also refresh when the parent views datapath is reset. Is this acurate?


Yes, that's how it's supposed to work.

-Antun