Hi It did not work with both solutions suggested. I removed if statement and tried with both for loop and while loop as suggested, but iterator() method does not work.
It still goes into the loop for second child and throws NullPointerException. Thanks Arti -----Original Message----- From: Raj Saini [mailto:[EMAIL PROTECTED] Sent: Friday, April 21, 2006 2:03 PM To: MyFaces Discussion Subject: Re: getChildren().iterator() problem Better approach is to use for loop. for (Iterator kids = myComponent.getChildren().iterator(); kids.hasNext();) { UIComponent child = (UIComponent)kids.next(); ... } On 4/21/06, Jesse Alexander (KSFD 121) <[EMAIL PROTECTED]> wrote: > > 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 > >

