1 Reply Latest reply on Jun 9, 2009 12:07 AM by Nick Belaevski

    Why would you use the switchType="ajax" in a tree?

    Derk Dukker Novice

      Hi all,
      I accidentally posted the question below in the richfaces design forum, sorry about that Nick. So here my question again in the right form :)

      I have a question about the switchType="ajax" in a tree. When would you use this? I have a tree in client mode with ajaxSubmitSelection="true" and a nodeSelectListener. When I click the last node in the tree, an ajax call is made and adds a bunch of nodes to the node I clicked. So that looks like an ajax thing to me. When I set the switchType to ajax it will make an ajax request for every node I click on. Why would you want that?
      Why would you use switchType="ajax" above "client"?



        • 1. Re: Why would you use the switchType=
          Nick Belaevski Master

          Hi Derk,

          Yes, some work has been done in order for the tree to be able to update the children incrementally. In fact, AJAX expansion/collapsion either as re-rendering on selection share almost the same code, so it should update smoothly.


          1. Yours solution is definitely more complicated for the end-developer, than simple usage of ajax-typed tree - e.g. because of the need to implement nodeSelectListener.

          2. You can expand/collapse tree node without selecting it.

          3. Some use cases require immediate server interaction for expansion and does not require this for selection at all.

          4. You can re-render node only without its children on selection, but still be able to expand/collapse it by AJAX.

          5. Does client-typed tree do correct demarcation between nodes and leaves if they are loaded partially?

          6. Collapsing tree nodes by AJAX removes them from the client, thus freeing browser memory.