0

I have a requirement where i need to use unique ID for each section rendered on the page. I thought of using TCM id of the component and tried to fetch that as
<span data-compId=${entity.ID}> in a JSP. But i am not able to fetch the value.

3

DXA decomposes TCM URIs; the ID of Entity Models correspond to the item reference ID of the TCM URI of the Component. In case of a DCP, the Entity Model ID is a combination of Component and Template ID.

Furthermore, you will find TCM URIs in the XpmMetadata but that is intended for (guess what?) XPM and not included on a Live environment.

Here’s an example of an Entity View that uses the Entity Model ID to construct an HTML ID: https://github.com/sdl/dxa-modules/blob/release/1.2/webapp-java/dxa-module-core/src/main/resources/META-INF/resources/WEB-INF/Views/Core/Entity/Carousel.jsp

P.S. DXA 1.2? Wow, that’s ancient! Considered upgrading?

  • Thanks Rick for your response. As per the reference jsp that you have given ${entity.id} has to work. Sure, we have a plan for upgrade. Hope it will happen soon :) – user3113876 Apr 5 at 9:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.