public void encodeTabLabel(FacesContext context, UITab tab) throws IOException {
ResponseWriter writer = context.getResponseWriter();
boolean disabled = tab.isDisabled();
UITabPanel pane = tab.getPane();
String method = tab.getSwitchTypeOrDefault();
boolean ajax = UISwitchablePanel.AJAX_METHOD.equals(method);
boolean clientSide = UISwitchablePanel.CLIENT_METHOD.equals(method);
String label = tab.getLabel();
if (label == null) {
label = "";
}
String clientId = tab.getClientId(context);
//String style = "position:relative; top:1px;" + (String) tab.getAttributes().get("style");
//TODO use CSS classes
String defShift = tab.isActive() ? "position:relative; top:1px;" : "position:relative;";
String componentStyle = (String) tab.getAttributes().get("style");
String style = defShift + (componentStyle != null ? componentStyle : "");
//TODO format code block properly
if (!disabled) {
if (clientSide) {
//TODO use StringBuilder
writer.writeAttribute(HTML.onclick_ATTRIBUTE, "if (RichFaces.onTabChange(event, '"+pane.getClientId(context)+"','"+
clientId+"')) RichFaces.switchTab('" +
pane.getClientId(context) + "','" + clientId + "','" +
getUtils().formatValue(context, pane, tab.getName()) + "');", "switchScript");
} else {
String activeCheck = "if (RichFaces.isTabActive('" + clientId + LABEL_SUFFIX + "')) return false;";
String eventCheck = " if (!RichFaces.onTabChange(event, '"+pane.getClientId(context)+"','"+clientId+"')) return false;";
if (ajax) {
JSFunction function = AjaxRendererUtils.buildAjaxFunction(tab,
context);
Map eventOptions = AjaxRendererUtils.buildEventOptions(context,