I usually prefer the while-loop for this kind of operation:
 
Iterator kids = myComponent.getChildren().iterator();
while (kids.hasNext()) {
  UIComponent child = (UIComponent)kids.next();
  ...
}
 
hth
Alexander


From: arti [mailto:[EMAIL PROTECTED]
Sent: Friday, April 21, 2006 12:25 PM
To: MyFaces Discussion
Subject: getChildren().iterator() problem

Hi,
 
I am facing a problem with getChildren().iterator(). (using getChildren().listIterator() works perfect)  Why?
 
My custom table component has just one child column element in it.
 
But still the iterator obtained as mentioned above, enters the following loop twice and second time throws NullPointerException
 
    Iterator kids = myComponent.getChildren().iterator();
    if (kids.hasnext()) {
        do {
            UICompoment child = kids.next();            // this line throws NullPointerException when executed second time in loop
            /* some code here */
        } while (kids.hasnext());
    }
 
Thanks
Arti
 

Reply via email to