TOC PREV NEXT INDEX




Direct-to-DOM Enabling the encodeEnd Method of the TabbedPaneRenderer


The modifications made to encodeEnd method use the ICEfaces public APIs in the DOMContext PassThroughAttributeRenderer classes as well as methods in the DomBasicRenderer, the superclass of the TabbedPaneRenderer.

1. The DOMContext is retrieved and attached to the UIComponent using the DOMContext attachDOMContext static method.
DOMContext domContext = DOMContext.attachDOMContext(facesContext,uiComponent);
 

 
if (!domContext.isInitialized()) {
 
Element table = domContext.createRootElement(HTML.TABLE_ELEM) ;
 
table.setAttribute(HTML.STYLE_ATTR,TABLE_STYLE) ;
 
table.setAttribute(HTML.CELLSPACING_ATTR, "0") ;
 
setRootElementId(facesContext, table, uiComponent) ;
 
}
 

 
2. Direct-to-DOM rendering requires that the TabbedPane be contained in a form. Unlike the MyFaces implementation, a parent form is required and a dummy form is not rendered automatically. If a parent form is not found, a form must be added to the JSP page.

 
// get the parentForm
 
UIForm parentForm = RendererUtils.findParentForm(tabbedPane) ;
 
// if there is no parent form output a message and stop rendering
 
if (parentForm == null) {
 
System.out.println("ERROR::TabbedPane::must be contained in a FORM") ;
 
return;
 
}
 
3. The response writer calls in the MyFaces implementation are replaced with DOM API calls. The calls to writer.startElement, writer.endElement, and writer.writeAttribute are no longer required. The Direct-to-DOM enabled renderer uses the DOMContext object to create new W3C DOM Elements and TextNodes. The W3C DOM API is used to set attributes and append children to DOM Elements. The following block of code is the Direct-to-DOM enabled replacement of the MyFaces writeTableStart method.
// get table, the table is the rootNode
 
Element table = (Element) domContext.getRootNode() ;
 
// render table pass thru attributes
 
for (int i = 0;i < HTML.TABLE_PASSTHROUGH_ATTRIBUTES.length;i++) { 
 
renderAttribute(tabbedPane, table, HTML.TABLE_PASSTHROUGH_ATTRIBUTES [i], 
 
			HTML.TABLE_PASSTHROUGH_ATTRIBUTES[i]);
 
}
 

 
table.removeAttribute(HTML.BGCOLOR_ATTR);
 

 
// clean out children remove the table rows from the table 
 
DOMContext.removeChildrenByTagNameName(table, HTML.TR_ELEM) ;
 

 


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

TOC PREV NEXT INDEX