9 Replies Latest reply on Jan 28, 2011 12:58 PM by apashkev

    Refresh rich:treeNode

    apashkev

                          <rich:menuItem onclick="alert('Delet pressed');" value="Delete">
                              <a4j:support event="onclick" action="repositoryAction.deleteFolder"/>
                          </rich:menuItem>

      Is it possible to refresh a single tree node in rich:tree ??

      I'm deleting items from tree, so I want to refresh the parent node.

       

      Thanks in advance.

        • 1. Re: Refresh rich:treeNode
          nbelaevski

          Hi Andriy,

           

          Yes, it's possible. Use ajaxKeys attribute for that.

          • 2. Re: Refresh rich:treeNode
            apashkev

            Hi, Nick!

            Thanks for the answer. Would you please provide me some example of doing the above thing. I can't find any samples  with ajaxKeys set to something that is not null.

             

            Regards

            • 3. Re: Refresh rich:treeNode
              nbelaevski
              • 4. Refresh rich:treeNode
                apashkev

                Hi Nick! I'm still facing some troubles with refreshing tree nodes, for now I've came up with a temporary solution, which however doesn't suite performance requirements.

                 

                I was trying to implement this feature using your advice and I've got a problem, with the following line :

                 

                HtmlTree tree = (HtmlTree) e.getComponent();

                it throws

                org.richfaces.component.html.HtmlTree cannot be cast to org.richfaces.component.html.HtmlTree

                 

                As the links you've provided are not showing the full code, I'd like to download a working demo with such an approach implemented. Is this possible?

                 

                Thanks in advance!

                • 5. Refresh rich:treeNode
                  nbelaevski

                  Hi Andriy,

                   

                  Most likely you are having two different instances of HtmlTree class in class path (e.g. one as EJB module dependnecy, another deployed in WAR/WEB-INF/lib). Is it so?

                  • 6. Refresh rich:treeNode
                    apashkev

                    Hi Nick! Thanks for a quick response. Yes! To be able to use HtmlTree in code behind I was forced to move it's dependencies to other project modules and they are contained in WAR as well. It is done because the project's WAR doesn't contain java code at all.

                    Is there a way to add those dependencies to EAR and use them in WAR? Dependecies are managed with Maven 2.


                    Best regards

                    Andriy

                    • 7. Refresh rich:treeNode
                      nbelaevski

                      Andriy,

                       

                      It is highly not recommended to operate over JSF components from EJB code, but possible to use generic UIComponent API like this:

                       

                      UIComponent t = e.getComponent();

                      Object rowKey = t.getAttributes().get("rowKey");

                      //do the needful

                       

                      JSF API is part of JEE5 server, so should be accessible from EJB beans.

                      • 8. Re: Refresh rich:treeNode
                        apashkev

                        Nick,

                        JSF API is accessible, but what I was trying to achieve looks like the following

                         

                        processSelection(NodeSelectedEvent e) {

                        HtmlTree tree = (HtmlTree)e.getComponent();

                        TreeRowKey parentKey = tree.getParentRowKey(tree.getRowKey());

                        ...

                        }

                         

                        is it possible to get parentRowKey from UIComponent ?

                        one more thing... is there a way to call processSelection on right mouse button click?

                         

                        Thanks

                        • 9. Refresh rich:treeNode
                          apashkev

                          Nick!

                          I've spent few hours working with tree component... and I'm wondering why changeExpandListener is never called ? ... I've also tried to add the following

                           

                           

                          <a4j:support event="onexpand"

                                          action="#{action.expandNode(_node)}" />

                           

                          however expandNode still doesn't gets called ...

                           

                          any ideas?...

                           

                          Regards

                          Andriy