[Laszlo-user] Data Manipulation Confusion
openlaszlo at wingspread.imap-mail.com
Wed Apr 12 15:28:49 EDT 2006
Actually I just looked again and the setPointer method *is* mentioned in
the hierarchy of LzDatapath in the LZ Reference documentation. I just
overlooked it (several times).
On Wed, 12 Apr 2006 15:18:45 -0400, James Howe
<openlaszlo at wingspread.imap-mail.com> wrote:
> Thanks. That did the trick. The one thing I had been missing was the
> 'setPointer' method on LzDatapath. I was looking at the reference
> documentation for LzDatapath and I did not see any reference to a
> 'setPointer' method. It's not listed as one of the methods inherited
> from LzDatapointer. The reference documentation for LzDatapointer does
> contain a description for setPointer. What had been confusing me was
> that I
> wasn't seeing a method which would let me change things based on a data
> node. The setPointer method was what I had missed.
> Thanks again and I think I'll file a documentation error report on the
> setPointer thing.
> On Wed, 12 Apr 2006 12:09:01 -0400, Adam Wolff <adam at laszlosystems.com>
>> Here's the general approach you want to take.
>> What you want to do is to hand your editor a LzDataElement that is
>> from the template. Note that this node doesn't need to be part of a
>> dataset; you can hand an xml node directly to a datapath that you've
>> <class name="editor" extends="window">
>> <!-- be sure to create a datapath, since we're not going to use
>> for databinding here -->
>> var newnode = template.getFirstChild().getFirstChild().cloneNode( true
>> editor.datapath.setPointer( newnode );
>> //user fills out form
>> //when user clicks ok
>> ds1.getFirstChild().appendChild( editor.datapath.p );
>> Hope this helps.
>> On Apr 11, James Howe wrote:
>>> I've been working on a data related problem for the last few days which
>>> really has me confused. I must be missing something. I'm trying to do
>>> something very simple. I have two XML datasets:
>>> <dataset name="ds1">
>>> <item name="foo" address="bar"/>
>>> <dataset name="template">
>>> <item name="" address=""/>
>>> I have a simple editor which is bound to ds1 with a datapath like this:
>>> The user can change things in the editor and save them. They can also
>>> select 'New' to start again. What I've been trying to figure out is
>>> to clone the item element from my template dataset and use it to
>>> the edited value found in ds1. Looking in the documentation I can see
>>> I could add the template item to ds1 and then delete the original node
>>> from ds1 using the addNodeFromPointer, but then if the user edits the
>>> values, the values in my template are disturbed. What I want to do is
>>> a deep clone of my template node to the ds1 dataset so that if/when it
>>> gets edited, my template remains unaffected.
>>> What am I missing? I can find the node I'm interested in by doing
>>> xpathQueries. I can clone the LzDataElement returned from the
>>> xpathQuery. Once I have that, I don't see how I can add that element
>>> as a
>>> node in my ds1 dataset.
>>> Any help on this would be greatly appreciated.
More information about the Laszlo-user