If I have a component id (for example tcm:9-123), is there a way to get its content? How can this be achieved in java ?
-
Is that components are DCP?– Velmurugan ♦Commented Mar 12, 2018 at 12:06
-
No, not DCP. We have based it on dxa's webapp-java project– RacheCommented Mar 12, 2018 at 12:14
-
Did you mean, if we are using DCP model to assemble content from the Content Data Store, then yes.– RacheCommented Mar 12, 2018 at 12:33
-
AFAIK - Yes, with DCP you can able to get component MVCData– Velmurugan ♦Commented Mar 12, 2018 at 12:52
-
Can you share some code, please, in java– RacheCommented Mar 12, 2018 at 13:18
|
Show 3 more comments
1 Answer
In general, you can’t get the content of Components separately on the CD side.
You can get the content of a Dynamic Component Presentation, though. In DXA, DCPs are represented as Entity Models with an ID like <ComponentID>-<TemplateID>
. For example: 123-234
for a DCP of Component tcm:x-123
rendered with Template tcm:x-234-32
.
You can use ContentProvider.getEntityModel
for this purpose.