cancel
Showing results for 
Search instead for 
Did you mean: 

cpoying elements

Former Member
0 Kudos

Hi All,

i am copying two node in to one node .how can copy that two nodes at a time to the node.can any body tell this its urgent...

check below...wat i did

if (wdContext.nodeBulkMatStatusXs() != null && wdContext.nodeBulkMatStatusXs().size() > 0)

{

WDCopyService.copyElements(wdContext.nodeBulkMatStatusXs(),wdContext.nodeBulkMatStatusSearchResultVN());

}

if(wdContext.nodeBulkMaterialTemp() !=null && wdContext.nodeBulkMaterialTemp().size()>0)

{

WDCopyService.copyElements(wdContext.nodeBulkMaterialTemp(),wdContext.nodeBulkMatStatusSearchResultVN());

}

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member485701
Active Participant
0 Kudos

Hi prasad,

In your code it will only copy the last node copied.

For resolving this issue do following thing.

copy first node like this.

(1)WDCopyService.copyElements(wdContext.nodeBulkMatStatusXs(),wdContext.nodeBulkMatStatusSearchResultVN());

(2)copy 2nd node like following

Iterator iter = wdContext.nodeBulkMaterialTemp().getNodeInfo().iterateAttributes();

for (int i = 0; i < wdContext.nodeBulkMaterialTemp().size(); i++) {

IWDNodeElement elem = wdContext.nodeBulkMatStatusSearchResultVN().createAndAddElement();

IWDNodeElement sourceEle = wdContext.nodeBulkMaterialTemp().getElementAt(i);

while(iter.hasNext()){

IWDAttributeInfo attr = (IWDAttributeInfo) iter.next();

String name=attr.getName();

elem.setAttributeValue(name, sourceEle.getAttributeValue(name));

}

}

This will solve your problem.

Regards,

Praveen

Former Member
0 Kudos

Hi Prasad,

WDCopyService provides u a few methods for copying the data.U can copy a single node at a time. If that node contains a child node & u want to copy main node with all the child nodes, u can use WDCopyService.copySubTree() method.

regards

Sumit

former_member197348
Active Contributor
0 Kudos

Hi Prasad,

What is exactly your problem? Using WDCopyService.copyElements throws <b>WDRuntimeException</b> - if target is a model node and source is <b>not</b> a model node holding the same class.

regards,

Siva