code: private void removeOldFacets()
      {
          Map<String, Object> attributes = component.getAttributes();
          List<String> currentComponents = createdFacets;
  
          // Get the old list of created component ids and update the current list as a
          // component attribute
          Object oldValue;
  
          if (currentComponents != null)
          {
              oldValue = attributes.put(JSP_CREATED_FACET_NAMES, currentComponents);
              createdFacets = null;
          }
          else
          {
              oldValue = attributes.remove(JSP_CREATED_FACET_NAMES);
          }
  
          // Remove old children that are no longer present
          if (oldValue != null)
          {
              List<String> oldList = TypedCollections.dynamicallyCastList((List)oldValue, String.class);
  
              int oldCount = oldList.size();
  
              if (oldCount > 0)
              {
                  if (currentComponents != null)
                  {
                      int currStartIndex = 0;
  
                      for (int oldIndex = 0; oldIndex < oldCount; oldIndex++)
                      {
                          String oldId = oldList.get(oldIndex);
  
                          int foundIndex = _indexOfStartingFrom(currentComponents, currStartIndex, oldId);
  
                          if (foundIndex != -1)
                          {
                              currStartIndex = foundIndex + 1;
                          }
                          else
                          {
                              component.getFacets().remove(oldId);
                          }
                      }
                  }
                  else
                  {
                      Map<String, UIComponent> facets = component.getFacets();
  
                      // All old facets need to be removed
                      for (String oldId : oldList)
                      {
                          facets.remove(oldId);
                      }
                  }
              }
          }
      }
docs: <p>Retrieve from the {@link UIComponent} corresponding to this tag
  handler the list of all facet names created by {@link UIComponentTag}
  instances the previous time this tree was rendered.  Compare it to the
  list of facets created during this page processing pass, and remove
  all facets present on the old list but not in the new list.  Save the
  list as a {@link UIComponent} attribute so that it gets saved as part
  of the component's state.</p>