I am using DD4T with java using odata web service. I am able to retrieve the content of whole page in java using odata. But I am not sure how can we get the values of individual elements to create the JSP pages. I have created Odata client and then used below code to retrieve content from odata:

String filter = String.format("PublicationId eq %d and Url eq '%s'", 176, "/example/test.html");

OEntity pageEntity1 = ODataClient.INSTANCE.getPageEntities().filter(filter).expand("PageContent").execute().firstOrNull();

OEntity pageContentEntity = pageEntity1.getLink("PageContent", OLink.class). getRelatedEntity();

System.out.println(pageContentEntity.getProperty("Content", String.class).getValue());

But this is giving content of whole page. I want content of individual field of component.

2 Answers 2


The code you pasted is part of the Page provider, as I highlighted on my blog post http://yatb.mitza.net/2014/06/odata-page-provider-dd4t-java.html. This code is solely responsible to handle communication with the CD Webservice (aka OData).

The provider is called by the PageFactory, which is responsible for 3 things:

  • handling caching, so you don't hit OData for every request
  • retrieval of the Page content from the provider (as a String representing a model serialized by the templates)
  • deserializing the content into a DD4T model object

So what you are missing is the PageFactory method getPageFromSource, which deserializes the page content into a GenericPage.

There are a number of XML/JSON serializers out there, so you can simply pick one and implement. In my latest project we used Jackson to handle JSON. A sample invoker to deserialize is:

public GenericPage getPageFromSource(String source) throws SerializationException {
    return SerializerFactory.deserialize(source, PageImpl.class);

The SerializerFactory returns a Serializer that uses Jackson API

 * Jackson's 2.3.3 ObjectMapper
private static final ObjectMapper mapper = new ObjectMapper();

public <T> T deserialize(final String content, final Class<T> aClass) throws SerializationException {
    try {
        return mapper.readValue(content, aClass);
    } catch (IOException e) {
        throw new SerializationException(e);

I can only assume that the content of the Components is available in the Component Presentations within that page, so you should probably expand your query to return the ComponentPresentations (something like odata.svc/Pages(PublicationId eq 123, Id eq 234)/ComponentPresentations))

  • I am able to get this data in java... But my question is how can I retrieve individual fields of component like title, subtitle etc from the retrieved content in my JSP page.
    – user1090
    Jul 15, 2014 at 12:55
  • Tridion doesn't publish that, DD4T does. The content of a Component Presentation with DD4T is a structured data format (XML IIRC). You need to load and parse that.
    – Nuno Linhares
    Jul 15, 2014 at 16:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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