public int doStartTag() throws JspException {
Object value = findAncestorWithClass(this, TabSetTag.class);
if (value == null) {
throw new JspException("TabHeadingsTag must be contained in a TabSetTag");
}
TabModel model = ((TabSetTag)value).getModel();
String bundle = ((TabSetTag)value).getBundle();
String locale = ((TabSetTag)value).getLocale();
String selectedTab = model.getSelectedTab();
String resourcePrefix = ((TabSetTag)value).getResourcePrefix();
StringBuffer buf = new StringBuffer();
buf.append("<div class=\"tabHeadings\">");
buf.append("<ul>");
for(int i = 0 ; i < model.getTabCount(); i++) {
String tabName = model.getTabName(i);
String tabTitle = model.getTabTitle(i);
String tabBundle = model.getTabBundle(i);
// List item
buf.append("<li id=\"tab_item_");
buf.append(tabName);
buf.append("\" class=\"");
if(selectedTab == null) {
buf.append(i == 0 ? "selectedTab" : "hiddenTab");
}
else {
buf.append(selectedTab.equals(tabName) ? "selectedTab" : "hiddenTab");
}
buf.append("\">");
// Link
buf.append("<a id=\"tab_link_");
buf.append(tabName);
buf.append("\" ");
if(selectedTab == null) {
buf.append(i == 0 ? "class=\"currentTab\" " : "");
}
else {
buf.append(selectedTab.equals(tabName) ? "class=\"currentTab\" " : "");
}
int idx = 0;
buf.append("onclick=\"javascript: var deselect = new Array();");
for(int j = 0 ; j < model.getTabCount(); j++) {
String tn = model.getTabName(j);
boolean s = tabName.equals(tn);
if(!s) {
buf.append("deselect[");
buf.append(idx++);
buf.append("]='");