1

I am using BrokerComponentPresentationProvider, to retrieve the component content by passing componentId and publication id. Provider returns null response,"Component Presentation not found for componentId: %d, templateId: %d and publicationId: %d";

please suggest how to retrieve the component content where we need to populate the content dynamically

public org.dd4t.contentmodel.ComponentPresentation getDynamicComponentPresentation(int componentId, int publicationId)

  • 1
    Can you elaborate on your use case and on what kind of logic you are trying to implement (custom controller?) For most use cases, we don't expect direct use of DD4T APIs. – Rick Pannekoek Feb 8 '16 at 18:51
  • Hi Rick, Our requirement is to populate banner content dynamically based on province and usersegment in every Page of our website.it is a responsive site.we have overwritten the default entity controller enrichModel method and trying to filter the banner components query works fine but getting the content of component from database is failing .component presentation is returning null it is not able to pull the component template with highest priority. – user2404968 Feb 9 '16 at 3:01
  • One more point in dd4t 2.01 version using GenericComponentFactory we were able to read the component content what is the replacement for this api method in dd4t 2.02 as these are removed in the latest version – user2404968 Feb 9 '16 at 3:11
  • If you managed to get a set of Component IDs out of a query and you know a CT ID, you can use ContentProvider.GetEntityModel to retrieve the DXA Entity Model. – Rick Pannekoek Feb 9 '16 at 18:43
1

Can you check the cd_core log to see what's happening and also whether the component presentation is actually published? What happens under the hood is that if you don't give a template Id, it will follow the old logic of calling:

 factory.getComponentPresentationWithHighestPriority(componentId);

This behaviour has not changed between dd4t 2.0.1 and 2.0.2.

In order to get the Component Presentation through the factory, if you don't have a template Id, you can do:

ComponentPresentationFactoryImpl.getInstance()
 .getComponentPresentation (componentURI, "tcm:0-0-0")

If you really want to keep on using the old GenericComponentFactory, you can also add the following dependency to your web application:

<dependency>
    <groupId>org.dd4t</groupId>
    <artifactId>dd4t-compatibility</artifactId>
    <version>${dd4t.version}</version>
</dependency>

which brings it back. Note that the logic will be the same as in the new ComponentPresentationFactory.

  • 1
    If it answered the question, you can mark it as accepted.. ;) – Raimond Feb 15 '16 at 19:01

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.