step 1:When a compnent with dataTable is added to tree dynamically in a ajaxListener, the component is pushed to com.sun.faces.context.StateContext in PostAddToViewEvent.
step 2:At render stage, com.sun.faces.application.view.FaceletViewHandlingStrategy.reapplyDynamicActions will process these added components. Howevever, the components under datatable in step 1 are added with a client ID without a rowindex. Suppose the datatable id is "dt", and a component under datatable is "comp". In step 1, the component is added as "dt:comp". Step 2 expects id like "dt:rowindex:comp". Therefore an error like this "serverError: class java.lang.NumberFormatException Trying to extract rowIndex from clientId" is thrown.
The component I added is a composite component created using JSF 2.2 API faceletFactory.createComponent("http://java.sun.com/jsf/composite/" + library, name, attrs); This error may be due to fact the added component is a composite component. I orignally added a component created programtically, I did not recall there is an error. But others also got this error using JSF 2.0: http://stackoverflow.com/questions/10717753/java-lang-numberformatexception-trying-to-extract-rowindex-from-clientid-j-idt