Understanding UIExtensionClass "Context Elements" and passing parameters to target page

I’m currently starting XWiki development, initially with a UIExtensionClass Admin Action menu point but still have some understanding problems or missing more documentation after reading …

Question 1: What exactly are the “Context Elements” I can select when creating a UIExtensionClass and how/where (in the Class code vs on the target page) to access them?

Question 2: In my case I create an additional Admin Menu entry. The target page needs the information which page was calling, what is the best practice to pass this information to the target page? Initially I used a url parameter but I think some kind of context usage would be better?

{{velocity}}{{html clean="false"}}
  #template('menus_macros.vm')
  #set($customUrl = "/xwiki/bin/view/Scratch/UixAdminAction?doc=" + $doc.fullName)
  #submenuitem($customUrl, "UixAdminAction", "UixAdminActionId", "UixAdminActionClass", "icon")
{{/html}}{{/velocity}}

From the documentation:

  • Context elements: The context information required during the execution of the extension (current user, current document, etc.). It’s also used to generate the cache key.

Using this only really make sense when you enable async or caching, as otherwise your code is executed in the current context so you have access to everything.