Hi,
My requirement is to generate a custom unique ID and save it in JCR on submission of dialog properties in "/content/dam".
I am planning to add a hidden field and write the logic in java for the same. But, how to invoke this model on submission of dialog without html?
Thanks and regards,
Vijaya Kumar A
Solved! Go to Solution.
Views
Replies
Total Likes
You can add a id on submission of the dialog with a PostProcessor:
Hi @vjleo94
Your problem is not very clear. Could you please try to explain it in detail? Which dialog you are trying to imply in /content/dam?
Is your requirement to create a unique component ID for a component and save it into JCR? If that is the case then you don't need to add a field in dialog until you want to see it in the dialog as well(which can be easily done by making the field disabled and giving the same name which you are setting from the backend then it would be prepopulated on page load), You can write your logic in Sling Model of your component and use ModifiableValueMap to save it into JCR.
Regards,
Arpit
Hi @vjleo94 ,
The requirement is not clear but I hope you understand that /content/dam is the path where we keep assets and, /content/<project_name> is where we keep content pages (html, where we configure component). Now, your requirement is to trigger Sling Model from the component without HTL, but why?
Sling Model is used to map the POJOs from Sling objects/resources and then use it on HTML/view.
If you just want to save something on JCR, then you can simply use Sling servletOSGI Service for the same.
In below video I have explained how can we trigger resource based sling servlet from script-
https://www.youtube.com/watch?v=iQu65qNN428&list=PLzwWOJSdKWBf7zLga8P7-ARxFQRwGGd94&index=6
Thanks,
Ritesh Mittal
Hi @Ritesh_Mittal and @ArpitVarshney ,
Thanks for the reply.
Firstly, it is not the component.
I have a custom metadata created dialog and added as properties for the dam assets. However, as part of this metadata I want to generate an unique ID and save it.
@Ritesh_Mittal , From your reply I see we can do it via the script by invoking the servlet. I will try it.
Thanks and regards,
Vijaya Kumar A
you can do it with javascript in the dialog on load event(if dialog is opening first time) and add keep value in the field either readonly or hidden.
You can add a id on submission of the dialog with a PostProcessor:
Views
Likes
Replies
Views
Likes
Replies