cancel
Showing results for 
Search instead for 
Did you mean: 

Copy value node to model node

Former Member
0 Kudos

Hi all,

I need to copy my value node to a model node but using

WDCopyService.copySubtree((IWDNode)ValueNode,(IWDNode)ModelNode);

I get the exception "Nodes are incompatible" even if they have the same structure.

Any helps?

Stefano

Accepted Solutions (1)

Accepted Solutions (1)

monalisa_biswal
Contributor
0 Kudos

Copyingd data from value node to model node is not possible because model node holds reference whose information is not there in value node.

What u can do

1>u can iterate over value node.

2>Get the reference of parent model node.

3>Add objects of child model node to the parent model node.

4>Copy values wusing copy corresponding method.

<Parent Model Node's class> input = new <Parent Model Node's class>();

wdContext.node<Parent Model Node>().bind(input);

int size=wdContext.node<value node>().size();

for(int i=0;i<size;i++)

{

IWDNode el=wdContext.node<value node>().getElementAt(i);

input.add<ChildNode>(new <ChildNodeModelClass>());

wdContext.node<ChildNode>.moveLast();

wdCopyservice.copyCorresponding(el,wdContext.current<ChildModelNode>);

}

Former Member
0 Kudos

Hi Monalisa,

your solution could be nice but what about child node? How can I manage the copy of a deep structure like this:


+Parent
  +Child1
    +Child1.1
  +Child2
    +Child2.1
    +Child2.2

Thank you again!

Answers (1)

Answers (1)

Former Member
0 Kudos

hi stefan,

Check out this thread.

Regards,

Gopi

Former Member
0 Kudos

Hi Gopi,

the link doesn't work, is it correct?

Stefano

Former Member
0 Kudos

hi,

Check out this.

regards,

Gopi

Former Member
0 Kudos

Hi Gopi,

the thread you suggest talks about copying ModelNode to ValueNode that for me works well.

In my application I get data from a model and I transfer these data using:

WDCopyService.copySubtree((IWDNode)myModelGetDataNode,(IWDNode)myValueNode);

Then the user can change these data and I need to re-transfer them to the save model:

WDCopyService.copySubtree((IWDNode)myValueNode,(IWDNode)myModelSaveDataNode);

This second step doesn't work and it raise the exception "Nodes are incompatible".

The structure used by the 2 Model are identical.

Thank u again,

Stefano