TOC PREV NEXT INDEX




Direct-to-DOM Enable the Existing writeSubHeaderCells Method Implementation


1. As in the previous method, writeHeaderCell, the ResponseWriter is no longer used. A DOMContext object is required as well as a reference to a table row Element.
protected void writeSubHeaderCells(DOMContext domContext,
 
FacesContext facesContext,
 
HtmlPanelTabbedPane tabbedPane,
 
int visibleTabCount,
 
int visibleTabSelectedIndex,
 
boolean disabled,
 
Element tr)
 
throws IOException {
 
StringBuffer buf = new StringBuffer() ;
 
for (int i = 0, cnt = visibleTabCount + 1; i < cnt; i++ ) {
 
Element td = domContext.createElement(HTML.TD_ELEM) ;
 
buf.setLength(0) ;
 
buf.append(SUB_HEADER_CELL_STYLE) ;
 
buf.append("border-top:").append(i == visibleTabSelectedIndex ? 
 
NO_BORDER_STYLE : BORDER_STYLE);
 
buf.append("border-right:").append(i + 1 < cnt ? NO_BORDER_STYLE : 
 
BORDER_STYLE);
 
buf.append("border-left:").append(i > 0 ? NO_BORDER_STYLE : BORDER_STYLE);
 
buf.append("background-color:").append(tabbedPane.getBgcolor());
 
td.setAttribute(HTML.STYLE_ATTR,buf.toString()); 
 
if (i == visibleTabSelectedIndex) {
 
renderAttribute(tabbedPane, td, "activeSubStyleClass", HTML.CLASS_ATTR) ;
 
} else {
 
renderAttribute(tabbedPane, td, "inactiveTabStyleClass", HTML.CLASS_ATTR) ;
 
}
 
Text text = domContext.createTextNode("&#160;") ;
 
td.appendChild(text) ;
 
tr.appendChild(td) ;
 
} // end for
 
} // end writeSubHeaderCells
 
2. Another new table row Element is created using the domContext createElement method. This table row will hold the sub header cells of the tabbed pane.
Element tr2 = domContext.createElement(HTML.TR_ELEM);
 
3. Call the writeSubHeaderCells method passing in the domContext and the table row Element, tr2, which will contain the sub header cells.
writeSubHeaderCells(domContext,
 
facesContext,
 
tabbedPane,
 
visibleTabCount,
 
visibleTabSelectedIdx,
 
false,
 
tr2) ;
 
4. Append the new sub headers table row to the table.
table.appendChild(tr2);
 


Copyright 2005. ICEsoft Technologies, Inc.
http://www.icesoft.com

TOC PREV NEXT INDEX