3 Replies Latest reply on Feb 29, 2008 6:01 AM by lectrix

    Can't Get Tree to ReRender

    andrewbarton

      I am trying to use a tree to allow users to reorder nodes using drag and drop. So far, I have everything working but tree re-rendering / refreshing.

      A simplified version of the code demonstrating my issue is listed below:

      <a4j:form ajaxSubmit="false" id="treeForm" reRender="theCategoryTree">
       <a4j:log/>
       <rich:dragIndicator id="indicator" />
      
       <a4j:outputPanel id="treePanel">
       <rich:tree id="theCategoryTree" style="width:300px"
       nodeSelectListener="#{categoryTreeEditView.processSelection}"
       reRender="treePanel"
       ajaxSubmitSelection="true" switchType="ajax"
       value="#{categoryTreeEditView.tree}"
       adviseNodeOpened="#{categoryTreeEditView.isNodeExpanded}"
       var="category"
       binding="#{categoryTreeEditView.categoryTreeBinding}">
       <rich:treeNode dragIndicator=":indicator" dragType="node"
       ajaxSubmitSelection="true"
       dragValue="#{category}" dropValue="#{category}"
       acceptedTypes="node"
       dropListener="#{categoryTreeEditView.processDrop}"
       reRender="treePanel">
       <h:outputText value="#{category.name}" />
       </rich:treeNode>
       </rich:tree>
       </a4j:outputPanel>
       </a4j:form>


      When dragging one node to another, a move / reorder operation will occur. I can see all of this taking place in my application server logs. But, the tree component does not reflect the change. If I click on another tree node after performing a drag operation, the tree does refresh and the tree reflects the correct state.

      I did notice if I set ajaxSubmit="true" the auto-refresh of the tree does function. But, ajaxSubmit="true" breaks other parts of my application (ultimately I need to support file upload and ajaxSubmit="true" definitely precludes this. I also have the option of using a jenia4face popupFrame to create a place to perform file upload, but again ajaxSubmit="true" breaks the popupFrame).

      Is there a way to cause a rich tree refresh after a drop operation?

      Thanks for any suggestions.

        • 1. Re: Can't Get Tree to ReRender
          maksimkaszynski

          Maybe, treePanel is not visible from treeNode?
          Tree is NamingContainer, BTW

          • 2. Re: Can't Get Tree to ReRender
            andrewbarton

            Maksim, assuming I have understood your comment, then you are suggesting I try the following:

            <a4j:form ajaxSubmit="false" id="treeForm" reRender="theCategoryTree">
             <a4j:log/>
             <rich:dragIndicator id="indicator" />
            
             <a4j:outputPanel id="treePanel">
             <rich:tree id="theCategoryTree" style="width:300px"
             nodeSelectListener="#{categoryTreeEditView.processSelection}"
             reRender="theCategoryTree"
             ajaxSubmitSelection="true" switchType="ajax"
             value="#{categoryTreeEditView.tree}"
             adviseNodeOpened="#{categoryTreeEditView.isNodeExpanded}"
             var="category"
             binding="#{categoryTreeEditView.categoryTreeBinding}">
             <rich:treeNode dragIndicator=":indicator" dragType="node"
             ajaxSubmitSelection="true"
             dragValue="#{category}" dropValue="#{category}"
             acceptedTypes="node"
             dropListener="#{categoryTreeEditView.processDrop}"
             reRender="theCategoryTree">
             <h:outputText value="#{category.name}" />
             </rich:treeNode>
             </rich:tree>
             </a4j:outputPanel>
             </a4j:form>


            Unfortunately, this makes no difference in the functionality. I have also tried using the following reRender values: 'treeForm', 'treeForm:treePanel','treeForm:treePanel:theCategoryTree'. None of these result in any change accept the last - 'treeForm:treePanel:theCategoryTree'. This reRender value makes the tree go blank until I refresh the page. Perhaps this is progress of sorts.

            Am I specifying the reRender values correctly?

            • 3. Re: Can't Get Tree to ReRender
              lectrix

              hello andrewbarton,
              did you manage to rerender the tree?
              i am getting a strange javascript error after successfully rerendering the tree component when i click on a node:
              "component has no properties" in event.js.jsf

              do you have a working example of rerendering a tree ondrop?

              thanks
              br
              stefan.