UUID e.g. as macro-param when inserting macro

Is there a way to set a UUID as the default value of a macro parameter?

What I would like to achieve is that a UUID is generated which can then also be addressed as a DOM ID using Javascript and for this UUID I can use Rest-Api to reload properties from an object based on a class that I have previously created via Rest-Api.
Some properties of this object can then be changed on the client side.

This UUID, which is generated when the macro is inserted, would serve as a link between the macro and the object.

Do you have any ideas on how I can achieve this?

Hi,

we’re using this kind of mechanism in the mention macro, by relying on some javascript to create an anchor with a UUID, here: xwiki-platform/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-ui/src/main/resources/XWiki/Mentions/MentionsMacro.xml at master · xwiki/xwiki-platform · GitHub

But AFAIR this mechanism only works when using the macro in the WYSIWYG editor. Another solution, if you’re using a Java Macro, is to just have the constructor of your macro parameters class set a UUID for your specific parameter default value, but then you’d need to ensure that this value is somehow insert if you’re using the wiki editor.

I think @rjakse had the same need not long ago but I’m not sure how he solved it in the end.

Sorry, I don’t remember about this, but if you remember more context, don’t hesitate to tell more.