![]()
Direct-to-DOM Enable the Existing writeTabCell Implementation
1. As in the previous methods, writeHeaderCell and writeSubHeaderCells, the ResponseWriter is no longer used. A DOMContext object is required as well as a reference to a table row Element. The table row will contain the tab cells.
protected void writeTabCell(DOMContext domContext, FacesContext facesContext, HtmlPanelTabbedPane tabbedPane, int tabCount, int selectedIndex, Element tr) throws IOException { Element td = domContext.createElement(HTML.TD_ELEM); td.setAttribute(HTML.COLSPAN_ATTR,Integer.toString(tabCount + 1)); td.setAttribute(HTML.STYLE_ATTR,TAB_CELL_STYLE + "background-color:" + tabbedPane.getBgcolor()); renderAttribute(tabbedPane, td, "tabContentStyleClass", HTML.CLASS_ATTR) ; // the DOMContext setCursorParent method is used to set the // cursor parent to the new table data Element before rendering // its children. This will cause the children to be appended to // new table data Element. domContext.setCursorParent(td) ; int tabIdx = 0; List children = tabbedPane.getChildren() ; for (int i = 0, len = children.size(); i < len; i++ ) { UIComponent child = getUIComponent((UIComponent)children.get(i)) ; if (child instanceof HtmlPanelTab) { if (tabIdx == selectedIndex) { RendererUtils.renderChild(facesContext, child) ; } tabIdx++ ; } else { RendererUtils.renderChild(facesContext, child) ; } } tr.appendChild(td) ; } // end writeTabCell2. A new table row element is created using the domContext createElement method. This table row will contain the Tab Cells.
Element tr3 = domContext.createElement(HTML.TR_ELEM);3. The writeTabCell method is called passing in the domContext and a table row Element to contain the Tab Cells.
writeTabCell(domContext, facesContext, tabbedPane, visibleTabCount, selectedIndex, tr3) ;table.appendChild(tr3);5. The DOMContext stepOver method is called. The stepOver method moves the cursor to the position where the next sibling should be rendered.
domContext.stepOver();
|
Copyright 2005. ICEsoft Technologies, Inc. http://www.icesoft.com |