for (int i = 0, size = clientIdsRemoved.size(); i < size; i++)
{
String clientId = clientIdsRemoved.get(i);
if (!idsRemovedSet.contains(clientId))
{
view.invokeOnComponent(context, clientId, new ContextCallback()
{
public void invokeContextCallback(FacesContext context,
UIComponent target)
{
if (target.getParent() != null)
{
if (!target.getParent().getChildren().remove(target))
{
String key = null;
if (target.getParent().getFacetCount() > 0)
{
for (Map.Entry<String, UIComponent> entry :
target.getParent().getFacets().entrySet())
{
if (entry.getValue()==target)
{
key = entry.getKey();
break;
}
}
}
if (key != null)
{
target.getParent().getFacets().remove(key);
}
}
}
}
});
idsRemovedSet.add(clientId);
}
}
clientIdsRemoved.clear();
clientIdsRemoved.addAll(idsRemovedSet);
}
finally
{
context.getAttributes().remove(FaceletViewDeclarationLanguage.REMOVING_COMPONENTS_BUILD);
}
}
List<String> clientIdsAdded = getClientIdsAdded(view);
if (clientIdsAdded != null)
{
Set<String> idsAddedSet = new HashSet<String>(HashMapUtils.calcCapacity(clientIdsAdded.size()));
// perf: clientIds are ArrayList: see method setClientsIdsAdded(String)
for (int i = 0, size = clientIdsAdded.size(); i < size; i++)
{
String clientId = clientIdsAdded.get(i);
if (!idsAddedSet.contains(clientId))
{
final AttachedFullStateWrapper wrapper = (AttachedFullStateWrapper) states.get(clientId);
if (wrapper != null)
{
final Object[] addedState = (Object[]) wrapper.getWrappedStateObject();
if (addedState != null)
{
if (addedState.length == 2)
{
view = (UIViewRoot)
internalRestoreTreeStructure((TreeStructComponent) addedState[0]);
view.processRestoreState(context, addedState[1]);
break;
}
else
{
final String parentClientId = (String) addedState[0];
view.invokeOnComponent(context, parentClientId, new ContextCallback()
{
public void invokeContextCallback(FacesContext context,
UIComponent target)
{
if (addedState[1] != null)