cancel
Showing results for 
Search instead for 
Did you mean: 

copying data from model nodes to value nodes

Yashpal
Active Contributor
0 Kudos

Hi All,

Is there any efficient way to copy data from model nodes to value nodes without writing the long code like wdcontext.currentnodenameElement.setAttributeName(wdcontext.nodeModelNodeelement.getAttributeElentmtAt.getAttributeName()) if the attributes are in large no its tedious to write code so is there any method for that . note: model nodes and value node name are same and they have same attributes.

Thanks.

Yashpal

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Yashpal,

You can copy all the elements of a node to another node through the WDCopyService.copyElements(sourceNode,destNode) method, provided they have the same attributes.

WDCopyService.copyElements(

wdContext.node<your modelnode>(),wdContext.node<your value node>()

);

Hope this helps,

Best Regards,

Nibu.

Answers (2)

Answers (2)

chintan_virani
Active Contributor
0 Kudos

Yash,

I found the following code while seraching this forum:-

you can copy the data in the model node like this

for(int i=0; i<wdcontext.node<model node name>.size(); i++)

{

iprivate<yourviewname or yourcontrollername>.i<valuenodename>element ve = wdcontext.create<valuenode>element();

ve.set<attributename>(wdcontext.node<modelnodename>.getElementAt(i).get<Attribute name>();

// this way set all the coreesponding attributes of model node and vale node

wdcontext.node<valuenodename>.addElement(ve);

}

Regards,

Chintan Virani.

chintan_virani
Active Contributor
0 Kudos

Hey YashPal,

IMO i guess you have follow this tedious procedure.

Regards,

Chintan Virani.