@Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
if (!RenderKitUtils.assertValid(context, component)) {
return;
}
final UIBodyDesktop uibd = (UIBodyDesktop) component;
boolean declarePageWrapper = true;
boolean declareDockWrapper = true;
for (UIComponent uIComponent : uibd.getChildren()) {
if (uIComponent instanceof UIBodyPageWrapper) {
declarePageWrapper = false;
}
if (uIComponent instanceof UIBodyDockWrapper) {
declareDockWrapper = false;
}
}
if (declareDockWrapper) {
Logger.getLogger(BodyDesktopRenderer.class.getName()).log(Level.FINEST, "Adding a dock wrapper to the desktop");
final UIBodyDockWrapper uibdw = new UIBodyDockWrapper();
uibd.getChildren().add(uibdw);
}
if (declarePageWrapper) {
Logger.getLogger(BodyDesktopRenderer.class.getName()).log(Level.FINEST, "Adding a page wrapper to the desktop");
final UIBodyPageWrapper uibpw = new UIBodyPageWrapper();
uibd.getChildren().add(uibpw);
}
//Fix this div id for help Mocha to know where start the desktop
uibd.setId(DESKTOP_ID);
super.encodeBegin(context, uibd);
}