12 Replies Latest reply on Oct 18, 2010 2:27 AM by Ashutosh Pradhan

    Having problem with Tree control node selected event

    scott david Newbie

      hi,
      i have a tree control which gets loaded at the start of the web app. the tree bean loads data from a database. the tree has around 1800 nodes/leafs.
      i have two issues here..

      first the tree is taking a long time to load(about 30 seconds).

      second, when i click on a node/leaf it is taking close to 3 minutes to reach my processselection event handler. the event handler is in the tree bean itself.

      i'm not doing any fancy stuff here. just loading values from database and populating them on the tree.

      when i tried my code with hard coded values for nodes/leaf, the loading and event handling is faster.

      but i wonder 1800 records shouldn't slow the tree very much.



      is there any examples of how to do this efficiently.


      the following is my code.

      <rich:tree switchType="client" nodeSelectListener="
      #{treeBean.processSelection}"
      value="#{treeBean.treeNode}"
      ajaxSubmitSelection="true"
      preserveModel="state"
      var="item" ajaxKeys="#{null}">
      /rich:tree>


      also is there any way to do lazy loading of the data?

      i appreciate any help that you can provide me.
      thanks
      scott

        • 1. Re: Having problem with Tree control node selected event
          Nick Belaevski Master

          Hello Scott,

          Please add phase tracker: http://www.jsftutorials.net/faces-config/phaseTracker.html and post its log for different operations (e.g. rendering and selection) in order to see where the time is spent.

          Tree requests from model only the data that is actually used. You can implement lazy-loading at TreeNode level, by implementing its methods in a proper way.

          • 2. Re: Having problem with Tree control node selected event
            scott david Newbie

            Hi.. Thanks for the reply. I download the phaselistener from the link that you provided and put it under WEB-INF/lib directory but I didn't see any logging. Also the file was a zip, not a jar. So I changed the extension to jar and it didn't do any logging for me. Actually I don't have any logging yet on my application and all my messages are output to the system console. Am I missing something here?

            Also could you please send me any examples of lazy loading of tree node if you have any?

            Thanks
            Scott.

            • 3. Re: Having problem with Tree control node selected event
              Nick Belaevski Master

              Here is the direct link to .jar file: http://www.jsftutorials.net/download/phaseTracker/phaseTracker.jar.

              About lazy loading: you can implement this interface: org.richfaces.model.TreeNode or extend this class: org.richfaces.model.TreeNodeImpl and add lazy-loading functionality. Main methods to handle: getChild(), getChildren(), getParent(), isLeaf().

              Method getData() can be implemented in the following way:

              public Object getData() {return this;}


              • 4. Re: Having problem with Tree control node selected event
                scott david Newbie

                Hi,
                For the slowness in the processSelection event handler, is there any solution? I even tested my tree with hard coded values. My test tree has 4 levels of nodes(around 2000 total nodes/trees). When I click on any node/leaf, it takes approximately one and half a minute to receive the nodeSelectedEvent in the processSelection method.

                Does anyone noticed such a behavior? Is there any way to improve this?
                Is there any benchmark result available that I can use to compare my tree performance?

                • 5. Re: Having problem with Tree control node selected event
                  scott david Newbie

                  Here is my phasetracker log dump..

                  11:47:04,019 ERROR [STDERR] Feb 18, 2009 11:47:04 AM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER RENDER_RESPONSE 6
                  11:47:04,128 ERROR [STDERR] Feb 18, 2009 11:47:04 AM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE RESTORE_VIEW 1
                  11:47:04,128 ERROR [STDERR] Feb 18, 2009 11:47:04 AM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER RESTORE_VIEW 1
                  11:47:04,128 ERROR [STDERR] Feb 18, 2009 11:47:04 AM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE RENDER_RESPONSE 6
                  11:47:04,269 ERROR [STDERR] Feb 18, 2009 11:47:04 AM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER RENDER_RESPONSE 6
                  11:47:04,269 ERROR [STDERR] Feb 18, 2009 11:47:04 AM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE RESTORE_VIEW 1
                  11:47:04,269 ERROR [STDERR] Feb 18, 2009 11:47:04 AM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER RESTORE_VIEW 1
                  11:47:04,269 ERROR [STDERR] Feb 18, 2009 11:47:04 AM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE RENDER_RESPONSE 6
                  11:47:04,331 ERROR [STDERR] Feb 18, 2009 11:47:04 AM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER RENDER_RESPONSE 6
                  11:47:04,331 ERROR [STDERR] Feb 18, 2009 11:47:04 AM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE RESTORE_VIEW 1
                  11:47:04,331 ERROR [STDERR] Feb 18, 2009 11:47:04 AM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER RESTORE_VIEW 1
                  11:47:04,331 ERROR [STDERR] Feb 18, 2009 11:47:04 AM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE RENDER_RESPONSE 6
                  11:47:04,347 ERROR [STDERR] Feb 18, 2009 11:47:04 AM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER RENDER_RESPONSE 6
                  11:47:04,347 ERROR [STDERR] Feb 18, 2009 11:47:04 AM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE RESTORE_VIEW 1
                  11:47:04,347 ERROR [STDERR] Feb 18, 2009 11:47:04 AM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER RESTORE_VIEW 1
                  11:47:04,347 ERROR [STDERR] Feb 18, 2009 11:47:04 AM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE RENDER_RESPONSE 6
                  11:47:04,362 ERROR [STDERR] Feb 18, 2009 11:47:04 AM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER RENDER_RESPONSE 6
                  11:47:04,362 ERROR [STDERR] Feb 18, 2009 11:47:04 AM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE RESTORE_VIEW 1
                  11:47:04,362 ERROR [STDERR] Feb 18, 2009 11:47:04 AM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER RESTORE_VIEW 1
                  11:47:04,362 ERROR [STDERR] Feb 18, 2009 11:47:04 AM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE RENDER_RESPONSE 6
                  11:47:04,378 ERROR [STDERR] Feb 18, 2009 11:47:04 AM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER RENDER_RESPONSE 6
                  11:47:04,378 ERROR [STDERR] Feb 18, 2009 11:47:04 AM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE RESTORE_VIEW 1
                  11:47:04,378 ERROR [STDERR] Feb 18, 2009 11:47:04 AM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER RESTORE_VIEW 1
                  11:47:04,378 ERROR [STDERR] Feb 18, 2009 11:47:04 AM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE RENDER_RESPONSE 6
                  11:47:04,409 ERROR [STDERR] Feb 18, 2009 11:47:04 AM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER RENDER_RESPONSE 6
                  11:47:04,409 ERROR [STDERR] Feb 18, 2009 11:47:04 AM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE RESTORE_VIEW 1
                  11:47:04,409 ERROR [STDERR] Feb 18, 2009 11:47:04 AM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER RESTORE_VIEW 1
                  11:47:04,409 ERROR [STDERR] Feb 18, 2009 11:47:04 AM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE RENDER_RESPONSE 6
                  11:47:04,409 ERROR [STDERR] Feb 18, 2009 11:47:04 AM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER RENDER_RESPONSE 6

                  11:49:20,391 ERROR [STDERR] Feb 18, 2009 11:49:20 AM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE RESTORE_VIEW 1
                  11:49:20,407 ERROR [STDERR] Feb 18, 2009 11:49:20 AM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER RESTORE_VIEW 1
                  11:49:20,407 ERROR [STDERR] Feb 18, 2009 11:49:20 AM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE APPLY_REQUEST_VALUES 2
                  11:49:20,407 INFO [STDOUT] getTreeNode method called
                  11:49:20,688 ERROR [STDERR] Feb 18, 2009 11:49:20 AM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER APPLY_REQUEST_VALUES 2
                  11:49:20,688 ERROR [STDERR] Feb 18, 2009 11:49:20 AM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE PROCESS_VALIDATIONS 3
                  11:49:20,719 ERROR [STDERR] Feb 18, 2009 11:49:20 AM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER PROCESS_VALIDATIONS 3
                  11:49:20,719 ERROR [STDERR] Feb 18, 2009 11:49:20 AM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE UPDATE_MODEL_VALUES 4
                  11:49:20,782 INFO [STDOUT] Inside the processSelection event of tree bean:
                  11:49:20,782 INFO [STDOUT] The selected tree node is: LocationName0
                  11:49:20,782 ERROR [STDERR] Feb 18, 2009 11:49:20 AM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER UPDATE_MODEL_VALUES 4
                  11:49:20,782 ERROR [STDERR] Feb 18, 2009 11:49:20 AM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE INVOKE_APPLICATION 5
                  11:49:20,782 ERROR [STDERR] Feb 18, 2009 11:49:20 AM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER INVOKE_APPLICATION 5
                  11:49:20,782 ERROR [STDERR] Feb 18, 2009 11:49:20 AM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE RENDER_RESPONSE 6
                  11:49:20,782 INFO [STDOUT] getTreeNode method called
                  11:49:20,829 ERROR [STDERR] Feb 18, 2009 11:49:20 AM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER RENDER_RESPONSE 6

                  • 6. Re: Having problem with Tree control node selected event
                    scott david Newbie

                    hi guys,
                    any idea of how to solve this issue? I'm really struggling with the tree event processing performance. Would appreciate any help or insight .
                    Thanks.

                    • 7. Re: Having problem with Tree control node selected event
                      Nick Belaevski Master

                      I see that server processing takes less one second, so looks like problem on the client-side. Can you please create small example project demonstrating the issue?

                      • 8. Re: Having problem with Tree control node selected event
                        Ashutosh Pradhan Newbie

                        Hi Scott , can post your code snippet , How you have load data  into rich:tree from database.

                         

                        Thanks

                        Ashu

                        • 9. Re: Having problem with Tree control node selected event
                          Ashutosh Pradhan Newbie

                          Hi Scott , could tou please send me your code snippet because i got the requirment to loads data from database. I am not able to do the same.


                          Please Please send me the code.(Very very urgent for me)


                          Thank you very much

                           

                          Thanks

                          Ashutosh

                          • 10. Re: Having problem with Tree control node selected event
                            Ashutosh Pradhan Newbie

                            Hi Nick,

                             

                            Can you tell me  , How to  load data from databse  into rich:tree(It's urgent my dear friend , Please help me). Wating for your reply

                             

                            Thank you very much

                             

                            Regard,

                            Ashutosh

                            • 12. Re: Having problem with Tree control node selected event
                              Ashutosh Pradhan Newbie

                              Hi Nick ,

                               

                                 Thank you

                               

                                 The  links are helpful but  I need some code snippet (Load data from database) with datamodel because I have to show the 5 level tree   .Till now i am not able to load the data from database.

                               

                               

                              (It's urgent my dear friend , Please help me).

                               

                              Thank you very much

                               

                               

                              Thanks,
                              Ashutosh