PDA

View Full Version : Datapath node


k-billy
08-08-2003, 11:30 AM
Hi Antun,

first, thanks for your help yesterday with regards the pagination problem. Using the datapath as a child node and setting the 'pooling' attribute to true definitely improved the performance of my component.

However, I am encountering a new problem with the datapath node. I am putting a javascript expression into the datapath's 'xpath' attribute. It looks like this:

-----code-----
<view name='datarow'>
<datapath xpath="${classroot.getAttribute('replicationPath')}" replication='normal' pooling="true"/>

<method event="ondata">
//reset the key each time data is reloaded
var keyfname = classroot.getColumnDataPointer("columns/").getXPath('@keyfname');
this.setAttribute('key', this.datapath.getXPath(keyfname));

if(classroot.getAttribute('initialized') == 'false'){
var lz = classroot.getColumnDataPointer("columns/column[1]");

do{

var lztxt = new LzText(this, null);
var fname= lz.getXPath('@fname');
var initWidth = lz.getXPath('@initwidth');
lztxt.setAttribute('datapath', fname);
lztxt.setAttribute('name', 'displaytxt');
lztxt.setAttribute('width', initWidth);

}while(lz.selectNext());
}
</method>
</view>

----end of code-------

When I hard-code the xpath attribute, the datapath gets created at the correct time and the datarow's children views are able to access the necessary data.

However, when I use the Javascript expression (I have confirmed that it is correct) thehe datapath node is getting initialized 'after' the parent node's 'ondata' method is called. The result of this is that the datarow's child views don't have any content (i.e. because the datapath object hasn't been created yet).

Is there any way to control the order in which nodes get created, or do you see any flaw in the code?

Regards,

Caleb

antun
08-08-2003, 01:36 PM
Hey Caleb

I've been trying to figure out what the problem is, but I really need a little more to go on. I know there is a known bug with datapaths, where if you want to be able to change a datapath at runtime, you need to pass it an absoute XPath, rather than changing a relative one, but this sounds like a different kettle of fish.

You're saying that if you write:


<datapath xpath="${classroot.getAttribute('replicationPath')}"
replication='normal' pooling="true"/>


... instead of...


<datapath xpath="foo" replication='normal' pooling="true"/>


... then JavaScript in your <method> that gets called ondata doesn't have access to the subviews of the replicated view? Is that right?

Can you boil it to a simple test case - when I ran yours it seemed to depend on a lot of external code, so I couldn't see what the problem was.

-Antun

k-billy
08-11-2003, 07:25 AM
Hi Antun,

I tried reproducing the problem in a test case over the weekend. Unfortunately (for me), the test case worked :-) (it didn't replicate the problem) so I couldn't submit it.

I couldn't figure out why I was having the problem with the datapath node, but basically it seems that various attributes (in this case the 'xpath' attribute)in the component were not being initialized correctly the first time. Thus, the children views could not access data and weren't being created.

Anyways, I was able to resolve the problem by setting the xpath attribute of the datapath node during the 'oninit' event of the classroot.

I'm not sure why I had to do this, but it is working so I guess we can consider the issue resolved.

Caleb