PDA

View Full Version : format of adding datapointer


halfstep
01-03-2008, 10:12 AM
Hi, I'm using Chapter 38 of the guide to help add a node to a datapath from a form.

In my xml, the code looks like this:
<instance><serverUrl>http://whatever.com:8080</serverUrl><version>1.0</version></instance>

When I run the code its generating something that looks like this:
<instance serverUrl="http://whatever.com:8080" version="1.0"/>

I'm just wondering what I can do to have it create children elements instead of setting the editext value to an attribute.

Here is the code in my form:

<boxview name="newData" width="${parent.width * .95}" bordersize="1" xoffset="${parent.width * -.01}" yoffset="${parent.width * -.01}" datapath="new:/instance">
<simplelayout axis="y" spacing="0"/>
<boxview width="${parent.width}" bordersize="0" bgcolor="0x150F54" fgcolor="0xFFFFFF">
<text>Register Server Instance</text>
</boxview>
<view width="${parent.width}" height="100" bgcolor="0xDDDDDD" align="center">
<simplelayout axis="x" spacing="10"/>
<boxview bordersize="0" width="${parent.width * .25}">
<simplelayout axis="y" spacing="15"/>
<view><text width="${parent.width}">Service Endpoint:</text></view>
<view><text width="${parent.width}">Version:</text></view>
</boxview>
<view width="${parent.width/2}">
<simplelayout axis="y" spacing="15"/>
<edittext name="serviceUrl" width="${parent.width}" datapath="@serviceUrl"></edittext>
<edittext name="version" width="${parent.width}" datapath="@version"></edittext>
</view>
</view>
</boxview>
<datapointer name="insertPoint" xpath="myServices:/serviceFamily/service[1]"/>
<button style="blueComponents" align="right" width="${parent.width * .1}" xoffset="${parent.width * .01}" yoffset="${parent.width * -.03}" height="20">
<handler name="onclick">
Debug.write('starting to add to the dataset');
var dp = parent.insertPoint;
dp.selectChild();
parent.newData.datapath.updateData();
Debug.write(parent.newData.datapath);
dp.addNodeFromPointer(parent.newData.datapath);
Debug.write(dp);

</handler>
<text valign="middle" align="center" fgcolor="0xFFFFFF">Next</text>
</button>

rcyeager
02-13-2008, 07:14 PM
Instead of code snippets, can you provide a self-contained test program that demonstrates the issue?

Robert
http://www.qrowd.com
http://www.cooqy.com

kampfkolosso
02-13-2008, 10:39 PM
Hi Halfstep!
I think your problem is somewhere here:

<view width="${parent.width/2}">
<simplelayout axis="y" spacing="15"/>
<edittext name="serviceUrl" width="${parent.width}" datapath="@serviceUrl"/>
<edittext name="version" width="${parent.width}" datapath="@version"/>
</view>

This is your input, right? Ok, since you are using attribute referencing in the datapath, the updateData will of course store the data in attributes.
To get childobjects you should use something like "childobj/text()" to reference the content and hopefully it writes the data back there...

regards