on 03-13-2008 12:10 PM
Hi all
does anyone know how to copy the data from one node into another node which is identical to the first node without looping through one node and adding lines for each iteration of the loop?
thanks
Anton Kruse
Hi,
Make use of
WDCopyService.copyElements(source, target)
From the doc
Copies all elements from source to target
@param source The source node
@param target The target node
@throws RuntimeException if <code>target</code> is a model node and
source is not a model node holding the same class.
Ex:
WDCopyService.copyElements(wdContext.nodeTest(), wdContext.nodeTest1())
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
I really dont understand why you need to copy the wholw node all at once.
You can easily copy it by get and set methods
suppose you have : *test1
--atr1
--atr2
and *test2
--atr1
--atr2
so now to copy valus od test1.atr1 into test2.atr1
use,
wdcontext.currentTest1Elemet.setatr1(wdcontext.currentTest2Element.getatr1);
regards,
pinki
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Pinki,
As the node element names are identical we can save writing a few lines of code by using copyElements method. Moreover this also reduces error in our code (typo errors) and makes it easier to read. Other than that the way that you have suggested is fine.
Moreover, copyElements uses reflection to copy node elements, hence it consumes more memory and is slow while copying nodes with large number of elements.
Thanks,
Soujanya
User | Count |
---|---|
81 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.