cancel
Showing results for 
Search instead for 
Did you mean: 

Context iterateElements()

Former Member
0 Kudos

Hi experts,

I experience a strange behaviour with my model, the following iterator loop never gets called, despite the fact that "wdContext.nodeFindReturn()" is filled with many elements.

When I set a breakpoint before the loop, and inspect the context via the context debug viewer everything works as expected.

I guess by inspecting the context something in the context changes, which causes the iterator to work, any hints?


wdContext.nodeCustomerList().invalidate();
Iterator iter = wdContext.nodeFindReturn().iterateElements();

while (iter.hasNext())
{
	IWDNodeElement source = (IWDNodeElement) iter.next();
	IWDNodeElement destination = wdContext.nodeCustomerList().createAndAddCustomerListElement();

	WDCopyService.copyCorresponding(source, destination);
}

regards,

christian

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Try it the old way:

wdContext.nodeCustomerList().invalidate();
int size = wdContext.nodeFindReturn().size();
 
for(int i = 0; i < size; i++)
{
   IWDNodeElement source = wdContext.nodeFindReturn().getFindReturnElementAt(i);
   IWDNodeElement destination = wdContext.nodeCustomerList().createAndAddCustomerListElement();
 
   WDCopyService.copyCorresponding(source, destination);
}

Regards,

Satyajit.

Former Member
0 Kudos

Hi,

the "old way" works, so the iterator is broken?

regards,

christian

Former Member
0 Kudos

No it's not broken. The Javadoc explains the difference.

Armin

Former Member
0 Kudos

headdesk

next time i will not only rely on the javedoc presented in dev studio 😃

regards

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi

Why cant use "for" loop to get the elements and copy corresponding elements to another node.

Regards

Akshaya

Former Member
0 Kudos

Hi

In that case you may also try iterarteChildren() method that will give you all the nodes

Regards

Avinash

Former Member
0 Kudos

Hi,

the effect remains the same, hasNext() is only true after a context inspection.

regards,

christian

Former Member
0 Kudos

Hi

I think since this is a node...you may also use iterateAttributes() method to iterate through a node.

Thanks

Avinash

Former Member
0 Kudos

Hi,

i think iterateAttributes() won't help me here, because i need the nodes for my copyservice.

regards,

christian