Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-22145

Tree macro no longer works with dynamic content via reference parameter

    XMLWordPrintable

Details

    • Unknown
    • N/A
    • N/A

    Description

      I'm using the tree macro to generate a dynamic menu based on a page with JSON describing the menu.  Everything worked perfectly in 16.2.0, but since upgrading to 16.3.0 the menus are no longer displayed and I get the following error in the console:

       

      jquery.min.js?r=1:2 jQuery.Deferred exception: f.forEach is not a function TypeError: f.forEach is not a function at Object.<anonymous> (https://xwiki.lan/xwiki/webjars/wiki%3Axwiki/xwiki-platform-tree-webjar/16.3.0/tree.min.js?r=1:2:146) at e (https://xwiki.lan/xwiki/webjars/wiki%3Axwiki/jquery/3.7.1/jquery.min.js?r=1:2:27028) at t (https://xwiki.lan/xwiki/webjars/wiki%3Axwiki/jquery/3.7.1/jquery.min.js?r=1:2:27330) undefined

       

       

      The menu is displayed in a panel using the following code:

       

      {{velocity}}
      {{context document="$services.model.serialize($doc.documentReference)" transformationContext="document"}}
      ## If a local _menu has been found, display the menu panel
      #if($!localMenu)
        #set($pageref = $doc.getFullName())
        #set($json_ref = $!localMenu.replace(".WebHome", ".json"))
        #panelheader('Learning Path')
        {{tree reference="$json_ref" icons="false" edges="false" links="true" showRoot="false" openTo="$pageref" /}}
        #panelfooter()
      #end
      {{/context}}
      {{/velocity}}

       

      $localMenu is defined in a separate script block and is true in this case.

      The variable $json_ref points to a page with the following JSON:

       

      {"id":"Sandbox.sequential-menu-test.WebHome","text":"Sequential Menu Test","a_attr":{"href":"\/xwiki\/bin\/view\/Sandbox\/sequential-menu-test\/"},"children":[{"id":"Sandbox.sequential-menu-test.page1.WebHome","text":"Page 1","a_attr":{"href":"\/xwiki\/bin\/view\/Sandbox\/sequential-menu-test\/page1\/"}},{"id":"Sandbox.sequential-menu-test.page2.WebHome","text":"Page 2","a_attr":{"href":"\/xwiki\/bin\/view\/Sandbox\/sequential-menu-test\/page2\/"}},{"id":"Sandbox.sequential-menu-test.page3.WebHome","text":"Page 3","a_attr":{"href":"\/xwiki\/bin\/view\/Sandbox\/sequential-menu-test\/page3\/"}},{"id":"Sandbox.sequential-menu-test.page4.WebHome","text":"Page 4","a_attr":{"href":"\/xwiki\/bin\/view\/Sandbox\/sequential-menu-test\/page4\/"}},{"id":"Sandbox.sequential-menu-test.page5.WebHome","text":"Page 5","a_attr":{"href":"\/xwiki\/bin\/view\/Sandbox\/sequential-menu-test\/page5\/"}}]}

       

      In 16.2.0, this displays a tree/menu as expected with the tree opened to the current page.  In 16.3.0, nothing is displayed in the panel except the title.

       

       

      Attachments

        Issue Links

          Activity

            People

              MichaelHamann Michael Hamann
              Redhorse Rob Ostapiuk
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: