@Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
if (!RenderKitUtils.assertValid(context, component)) {
return;
}
final UIBodyDesktopHeader uibdh = (UIBodyDesktopHeader) component;
final UIDiv container = new UIDiv();
if (uibdh.isEnableApplicationTitleBar()) {
final UIDiv desktopTitlebarWrapper = new UIDiv();
final UIDiv desktopTitlebar = new UIDiv();
for (UIComponent uIComponent : uibdh.getChildren()) {
if (uIComponent instanceof UIBodyDesktopTopNavBar) {
desktopTitlebar.getChildren().add(uIComponent);
}
}
final UIDiv applicationTitleBar = new UIDiv();
desktopTitlebarWrapper.setId(DESKTOPTITLEBARWRAPPER_ID);
desktopTitlebar.setId(DESKTOPTITLEBAR_ID);
applicationTitleBar.setStyleClass(APPLICATIONTITLE_CLASS);
if (uibdh.getApplicationLogoURL() != null) {
final String logoUrl = "background: transparent url('" + uibdh.getApplicationLogoURL() + "') no-repeat scroll 0% 0%;";
desktopTitlebar.setStyle(logoUrl);
}
if (uibdh.getApplicationTitle() != null) {
final HtmlOutputText applicationTitle = new HtmlOutputText();
applicationTitle.setValue(uibdh.getApplicationTitle());
applicationTitle.setStyleClass(APPLICATIONTITLE_CLASS);
desktopTitlebar.getChildren().add(applicationTitle);
}
if (uibdh.getApplicationTagline() != null) {
final HtmlOutputText applicationTagline = new HtmlOutputText();
applicationTagline.setValue(uibdh.getApplicationTagline());
applicationTagline.setStyleClass(TAGLINE_CLASS);
desktopTitlebar.getChildren().add(applicationTagline);
}
desktopTitlebarWrapper.getChildren().add(desktopTitlebar);
uibdh.getChildren().add(desktopTitlebarWrapper);
} else {
for (UIComponent uIComponent : uibdh.getChildren()) {
if (uIComponent instanceof UIBodyDesktopTopNavBar) {
uIComponent.setRendered(false);
}
}
}
if (uibdh.isEnableApplicationMainNavBar()) {
final UIDiv desktopNavbarWrapper = new UIDiv();
desktopNavbarWrapper.setId(DESKTOPNAVBARWRAPPER_ID);
for (UIComponent uIComponent : uibdh.getChildren()) {
if (uIComponent instanceof UIBodyDesktopAppNavBar) {
UIBodyDesktopAppNavBar tmp = (UIBodyDesktopAppNavBar) uIComponent;
desktopNavbarWrapper.getChildren().add(tmp);
if (tmp.getStyle() != null){
desktopNavbarWrapper.setStyle(tmp.getStyle());
tmp.setStyle(null);
}
if (tmp.getStyleClass() != null){
desktopNavbarWrapper.setStyleClass(tmp.getStyleClass());
tmp.setStyleClass(null);
}
}
}
uibdh.getChildren().add(desktopNavbarWrapper);
} else {
for (UIComponent uIComponent : uibdh.getChildren()) {
if (uIComponent instanceof UIBodyDesktopAppNavBar) {
uIComponent.setRendered(false);
}
}
}
//Fix this div id for help Mocha to know where start the desktop
uibdh.setId(DESKTOPHEADER_ID);
super.encodeBegin(context, uibdh);
}