}
public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException {
UITabGroup component = (UITabGroup) uiComponent;
HtmlRendererUtil.createHeaderAndBodyStyles(facesContext, component);
layoutTabs(facesContext, component);
int activeIndex = ensureRenderedActiveIndex(facesContext, component);
final String clientId = component.getClientId(facesContext);
final String hiddenId = clientId + TabGroupRenderer.ACTIVE_INDEX_POSTFIX;
final String switchType = component.getSwitchType();
UIPage page = ComponentUtil.findPage(facesContext, component);
page.getScriptFiles().addAll(Arrays.asList(SCRIPTS));
if (TobagoConfig.getInstance(facesContext).isAjaxEnabled()) {
HtmlRendererUtil.writeScriptLoader(facesContext, SCRIPTS, new String[0]);
}
TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);
writer.startElement(HtmlConstants.INPUT, null);
writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
writer.writeAttribute(HtmlAttributes.VALUE, Integer.toString(activeIndex), false);
writer.writeNameAttribute(hiddenId);
writer.writeIdAttribute(hiddenId);
writer.endElement(HtmlConstants.INPUT);
String image1x1 = ResourceManagerUtil.getImageWithPath(facesContext, "image/1x1.gif");
TabList tabList = getTabList(facesContext, component);
// if a outer uiPage is presend, the virtual tab will go over all
// tabs and render it as they are selected, and it will
// selected with stylesheet.
int virtualTab = 0;
int currentWidth = 0;
int navigationBarWidth = 0;
if (ComponentUtil.getBooleanAttribute(component, TobagoConstants.ATTR_SHOW_NAVIGATION_BAR)) {
navigationBarWidth = getConfiguredValue(facesContext, component, "navigationBarWidth");
}
for (UIComponent tab : (List<UIComponent>) component.getChildren()) {
if (tab instanceof UIPanelBase) {
if (tab.isRendered()) {
currentWidth += tabList.getWidthList().get(virtualTab);
if (SWITCH_TYPE_CLIENT.equals(switchType) || virtualTab == activeIndex) {
if (virtualTab != activeIndex) {
HtmlRendererUtil.replaceStyleAttribute(component, "display", "none");
} else {
HtmlRendererUtil.removeStyleAttribute(component, "display");
}
writer.startElement(HtmlConstants.DIV, null);
writer.writeComment("empty div fix problem with mozilla and fieldset");
writer.endElement(HtmlConstants.DIV);
writer.startElement(HtmlConstants.DIV, null);
writer.writeIdAttribute(clientId);
StyleClasses classes = (StyleClasses) component.getAttributes().get(ATTR_STYLE_CLASS);
writer.writeClassAttribute(classes);
renderTabGroupView(facesContext, writer, component, virtualTab,
(HtmlStyleMap) component.getAttributes().get(ATTR_STYLE),
switchType, image1x1, navigationBarWidth, currentWidth, tabList);
writer.endElement(HtmlConstants.DIV);
if (TobagoConfig.getInstance(facesContext).isAjaxEnabled()
&& SWITCH_TYPE_RELOAD_TAB.equals(switchType)) {
final String[] cmds = {
"new Tobago.TabGroup(",
" '" + clientId + "', ",
" '" + activeIndex + "', ",
" '" + component.getChildCount() + "');"
};
HtmlRendererUtil.writeScriptLoader(facesContext, new String[0], cmds);
}
}
}