6 Replies Latest reply on Apr 7, 2011 5:16 AM by Manu Osten

    Problem with reRender at the dynamic rich:tree

    Manu Osten Apprentice

      Hello,

       

      I dont know, if it is bug, or not.

       

      I want to add or remove a child node in the tree. Adding a node in the tree is working, but removing is not working. If I select a node in the tree to remove it, the removing in the backing bean is working, but the tree on the website is not refreshing. If I press F5, then the tree is updating. WHY?? Setting on reRender is correct.

       

       

      JBoss 6.0

      Richface 3.3.3

      Seam 2

       

       

      <h:form  enctype="multipart/form-data">
      ..
      ..
      ..   
      
         <rich:tree id="dateTree" switchType="client" ajaxKeys="#{null}"
              showConnectingLines="false" styleClass="requestDateTree"
              ajaxSingle="true" ajaxSubmitSelection="true"
              adviseNodeSelected="#{requestGroupTreeHandler.adviseNodeSelected}"
              nodeSelectListener="#{requestGroupTreeHandler.processSelection}"
              adviseNodeOpened="#{requestGroupTreeHandler.adviseNodeOpened}"
              reRender="dateTree"
              value="#{requestGroupTreeHandler.dateNodes}" var="dateNode"
              eventsQueue="queueDateTree" ignoreDupResponses="true"
              nodeFace="#{dateNode.type}">
              <rich:treeNode type="date" nodeClass="dateNode">
                       ...
                       ...
                       ...
                  <ui:include src="viewDateForTree.xhtml">
                      <ui:param name="viewRequest" value="#{dateNode}" />
                  </ui:include>
              </rich:treeNode>
      
              <rich:treeNode type="interpreters">
                  ... 
                  ...
                  ...
              </rich:treeNode>
          </rich:tree>
      
      ..
      </h:form>
      

       

       

      RequestGroupTreeHandler.java

       

       

      ...
      ...
      ...   
      
          @SuppressWarnings("unchecked")
          public void processSelection(NodeSelectedEvent event) {
               System.out.println("processSelection");
               HtmlTree tree = (HtmlTree) event.getComponent();
                  TreeNode<ViewRequest> currentNode = tree.getModelTreeNode(tree.getRowKey());
                  ViewRequest selectednode = currentNode.getData();
                  if (selectednode.getRequest().getId() < 0) {
                      getRequestHandler().removeRequestFromGroup(selectednode);
                  } else {
                      getRequestHandler().changeSelectedRequest(selectednode);
                  }
                 System.out.println("finish the invoking processSelection");
              }
      
      ...
      ...
      
      
        • 1. Problem with reRender at the dynamic rich:tree
          Harut Sargsyan Apprentice

          Hi, try to enclose the tree in another top level component, and do reRender that top level component

           

          <h:panelGroup id="SOME_ID">

             <rich:tree.... 

          <:/h:panelGroup>

           

           

           

          ... reRender="SOME_ID"

          • 2. Problem with reRender at the dynamic rich:tree
            Manu Osten Apprentice

            Hi Harut,

             

            it is not working.

            • 3. Problem with reRender at the dynamic rich:tree
              Harut Sargsyan Apprentice

              Hi,

               

              set switchType="ajax" and remove ajaxSingle="true" and try again...

              • 4. Problem with reRender at the dynamic rich:tree
                Manu Osten Apprentice

                Hi,

                 

                sorry.. it is not working.

                • 5. Problem with reRender at the dynamic rich:tree
                  Harut Sargsyan Apprentice

                  Here is the part from one of my project, which works fine:

                   

                  TREE PART:

                  <h:panelGroup>           

                              <rich:spacer height="10px;"/>

                              <div style="overflow-x:auto; overflow-y:auto; width:420px; height: 540px; border: solid 1px #e5e3cc;">

                                  <h:panelGrid id="treePanel" cellpadding="0" cellspacing="0">

                                      <a4j:region>

                                          <rich:tree switchType="ajax"              

                                                     icon="../im/tree/node.png"

                                                     iconLeaf="#{item.imageInTree}"                  

                                                     ajaxSubmitSelection="true"

                                                     adviseNodeOpened="#{categoryController.adviseNodeOpened}"

                                                     adviseNodeSelected="#{categoryController.adviseNodeSelected}"

                                                     nodeSelectListener="#{categoryController.processSelection}"

                                                     changeExpandListener="#{categoryController.processExpansion}"                                                                                            

                                                     reRender="buttonsPanel, selectedNodePath, actionPanel"                                               

                                                     onexpand="Richfaces.showModalPanel('ajaxLoadingBarId')"

                                                     oncollapse="Richfaces.showModalPanel('ajaxLoadingBarId')"

                                                     onselected="Richfaces.showModalPanel('ajaxLoadingBarId')"

                                                     oncomplete="Richfaces.hideModalPanel('ajaxLoadingBarId')">

                                                    

                                              <rich:recursiveTreeNodesAdaptor

                                                      roots="#{categoryController.rootCategoryBean}"

                                                      var="item"

                                                      nodes="#{item.children}">

                                                                                     

                                                  <rich:treeNode>

                                                      <h:outputText value="#{item.name}" style="#{item.foundNodeStyle}"/>

                                                  </rich:treeNode>       

                                              </rich:recursiveTreeNodesAdaptor>

                                              

                                          </rich:tree>

                                      </a4j:region>

                                  </h:panelGrid>

                              </div>

                          </h:panelGroup>

                   

                   

                  ACTION BUTTON:

                   

                  <a4j:commandButton value="#{bundle['delete']}" styleClass="buttonImageSize"

                                                 onclick="if (!confirm('#{bundle['are.you.sure.delete.category']}')) return false; else Richfaces.showModalPanel('ajaxLoadingBarId');"

                                                 oncomplete="Richfaces.hideModalPanel('ajaxLoadingBarId')"

                                                 actionListener="#{categoryController.onDeleteCategory}"

                                                 reRender="buttonsPanel, selectedNodePath, treePanel, actionPanel"

                                                 disabled="#{categoryController.action &lt;= 1}"

                                                 immediate="true"/>

                  • 6. Problem with reRender at the dynamic rich:tree
                    Manu Osten Apprentice

                    I found the problem.

                     

                    At configuration "web.xml" I should set false into param of BUILD_BEFORE_RESTORE, then it is working. Fucking things!!!

                     

                    <context-param>

                            <param-name>facelets.BUILD_BEFORE_RESTORE</param-name>

                            <param-value>false</param-value>

                        </context-param>

                     

                     

                    Thank you for your help