2

I am using a rich:tree to display a large amount of data in my application. Each node has a considerable amount of HTML along with drag and drop support for reordering.

My problem is that when I drop a node into another, it seems that I have to re-render the whole tree. Is there a way I can chose which nodes to render. since re-order affects only certain nodes, re-rendering the whole tree seems to be unnecessary.

<rich:tree toggleType="ajax" var="node" id="segmentTree"
        nodeClass="rich-node-class" handleClass="abc" iconClass="cde"
        labelClass="node-lbl">
        <rich:treeModelRecursiveAdaptor
            roots="#{segmentationBean.treeAsList}" nodes="#{node.children}">
            <rich:treeNode id="treeNode" styleClass="treeNode" expanded="#{node.expanded}">

    <rich:dropTarget acceptedTypes="segments" dropValue="#{node}"
                        render="segmentTree"
                        dropListener="#{segmentationBean.onSegmentReorder}"
                        oncomplete="initializeTree();" />
                </a4j:outputPanel>
            </rich:treeNode>
        </rich:treeModelRecursiveAdaptor>
    </rich:tree>

Some more info: If i just try to render the "treeNode" the I see a NPE TreeRenderingContext:

public static TreeRenderingContext get(FacesContext context) {
        return (TreeRenderingContext) context.getAttributes().get(ATTRIBUTE_NAME);
    }

This method returns null for ATTRIBUTE_NAME = "org.richfaces.renderkit.TreeRenderingContext:ATTRIBUTE_NAME". Any help would be greatly appreciated. Thanks.

1
  • I was able to get the desired functionality. Here is the code <a4j:commandLink rendered="#{node.expanded}" render="treeNode" execute="segmentTree" oncomplete="initializeTree();"> <h:graphicImage library="images" styleClass="collapsed" name="segmentation/collapse.png" /> <a4j:param assignTo="#{node.expanded}" value="false" /> <f:param name="#{treeNodeBinding.clientId}__NEW_NODE_TOGGLE_STATE" value="true" /> <f:param name="#{treeNodeBinding.clientId}__TRIGGER_NODE_AJAX_UPDATE" value="true" /> </a4j:commandLink>
    – Amit Tikoo
    Nov 20, 2013 at 21:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.