public static UIComponent findChildByTagId ( UIComponent parent , String id ) { Iterator < UIComponent > itr = null ; if ( parent . getChildCount ( ) > 0 ) { for ( int i = 0 , childCount = parent . getChildCount ( ) ; i < childCount ; i ++ ) { UIComponent child = parent . getChildren ( ) . get ( i ) ; if ( id . equals ( child . getAttributes ( ) . get ( MARK_CREATED ) ) ) { return child ; } } } if ( parent . getFacetCount ( ) > 0 ) { itr = parent . getFacets ( ) . values ( ) . iterator ( ) ; while ( itr . hasNext ( ) ) { UIComponent facet = itr . next ( ) ; // check if this is a dynamically generated UIPanel if ( Boolean . TRUE . equals ( facet . getAttributes ( ) . get ( FACET_CREATED_UIPANEL_MARKER ) ) ) { // only check the children and facets of the panel if ( facet . getChildCount ( ) > 0 ) { for ( int i = 0 , childCount = facet . getChildCount ( ) ; i < childCount ; i ++ ) { UIComponent child = facet . getChildren ( ) . get ( i ) ; if ( id . equals ( child . getAttributes ( ) . get ( MARK_CREATED ) ) ) { return child ; } } } if ( facet . getFacetCount ( ) > 0 ) { Iterator < UIComponent > itr2 = facet . getFacets ( ) . values ( ) . iterator ( ) ; while ( itr2 . hasNext ( ) ) { UIComponent child = itr2 . next ( ) ; if ( id . equals ( child . getAttributes ( ) . get ( MARK_CREATED ) ) ) { return child ; } } } } else if ( id . equals ( facet . getAttributes ( ) . get ( MARK_CREATED ) ) ) { return facet ; } } } return null ; }
By TagId find Child