I'm working on a AEM project, and I have a component X. Along this component, I have another one which is a container of X. So, I can drag X instances and drop them onto the container.
To avoid problems between multiple instances of the component X, I assigned them an id, calling this Java function from the regarding X.jsp:
long id = System.currentTimeMillis();
Then, in the jsp, I have something similar to:
<div id='<%= id %>'>
</div>
Surprisingly for me, while inspecting the DOM with the Chrome Inspector, I have found a couple of repeated ids in my html structure. And of course, this caused a lot of problems.
I was able to fix this problem, by calling:
long id = System.nanoTime();
Am I going crazy and currentTimeMillis is returning repeated values? Is that possible?