facesContext.setViewRoot(viewRoot);
FlowHandler flowHandler = facesContext.getApplication().getFlowHandler();
if (flowHandler != null)
{
flowHandler.clientWindowTransition(facesContext);
}
// Publish an AfterAddToParent event with the created UIViewRoot as the event source.
application.publishEvent(facesContext, PostAddToViewEvent.class, viewRoot);
}