RenderingContext rc,
UIXHierarchy tree,
FacesBean bean
) throws IOException
{
FormData fd = rc.getFormData();
if (fd == null)
{
_LOG.warning("TREE_COMPONENT_MUST_INSIDE_FORM");
return;
}
ResponseWriter rw = context.getResponseWriter();
rw.startElement("div", tree);
renderId(context, tree);
renderAllAttributes(context, rc, tree, bean);
final String id = getClientId(context, tree);
UIComponent stamp = getFacet(tree, CoreTree.NODE_STAMP_FACET);
//@todo - will this tree.getFocusPath survive?
// List focusPath = getFocusPath(context, node);
Object focusPath = tree.getFocusRowKey();
String formName = fd.getName();
// Bug 3931544: don't use colons in Javascript variable names.
// We'll just replace colons with underscores; not perfect, but adequate
final String varName = "_adftree" + XhtmlUtils.getJSIdentifier(id);
boolean leftToRight = !rc.isRightToLeft();
int rootSize = tree.getRowCount();
RowKeySet state = getExpandedRowKeys(tree);
Map<Object, Boolean> selectedPaths = getSelectedPaths(focusPath);
// render each of the root nodes
for (int i = 0; i < rootSize; i++)
{
tree.setRowIndex(i);
_renderNode(context, rc, tree, bean, stamp, varName, state,
selectedPaths, new Boolean[_DEFAULT_TREE_DEPTH],
leftToRight, (i == 0), (i == rootSize - 1), 0);
}
//HKuhn - not needed in printable mode (scripting disabled)
if (supportsScripting(rc))
{
rw.startElement("script", null);
renderScriptDeferAttribute(context, rc);
renderScriptTypeAttribute(context, rc);
_renderTreeJS(context, rc, tree, bean);
//out.writeText("_setNodes('"+name+"','"+nodesRendered+"');");
String selectedParam =
id + NamingContainer.SEPARATOR_CHAR + SELECTED_PARAM;
String focusNodeId = TreeUtils.getFocusNodeClientId(context, tree);
rw.writeText("var " + varName + " = " +
_createNewJSSelectionState(formName, id, selectedParam,
focusNodeId), null);
rw.endElement("script");
fd.addNeededValue(selectedParam);
}
rw.endElement("div");
fd.addNeededValue(_PATH_PARAM);
}