4

I have an existing Java web app which will soon be making use of some components published from Tridion as files in DD4T format. I'm wondering which specific portions of the DXA or DD4T I can use just for the purpose of deserializing these XML files into objects.

What do I need to add to my maven repo? What do I need to add to my POM files? Is there a code snippet you can share which shows how the component data gets deserialized from the XML/JSON file into a Java object?

I just want to take the pieces I need from either DXA or DD4T - the JARs or other dependencies which help me get the component info from the published XML in the file system into a Java object in memory.

  • 1
    Xml file in what format? so those should be in DD4T format first. You can just use the consume the xml as lots of processing including link resolving etc involved. – Raj Kumar Dec 12 '15 at 6:22
  • @RajKumar the XML is in DD4T format. I just need to know how to get the classes in place to consume the XML. – CFL_Jeff Dec 12 '15 at 14:18
  • Using published XML is a common pattern for Tridion projects. Like Raj suggests, do keep link resolving and other tcdl logic in mind for your new requirements. You don't have to use DXA or DD4T, but they have solutions for Experience Manager, dynamic linking, External Content Libraries, and SmartTarget that you'll have to handle. – Alvin Reyes Dec 15 '15 at 10:15
  • It'll also be important to consider what you need in delivery since content is published as pages and Dynamic Component Presentations (and more recently Target Groups). The relationships, format, and template options differ between the two. – Alvin Reyes Dec 15 '15 at 10:20
5

DXA uses the DD4T serialization/deserialization because we wanted to adopt it as a future standard, so from that point of view I would say you are on the right approach of wanting to reuse it indeed.

As of DXA 1.1 we started using the JSON serialization which is part of DD4T 2.0 (DXA 1.1 used a custom build of DD4T 1.31 to add JSON support next to XML, as of DXA 1.2 we use the JSON only from DD4T 2.0) because that is smaller in size to the XML.

For starting with this I would indeed point you to the DD4T Templates project first https://github.com/dd4t/DD4T.TridionTemplates/releases (that is the part you need on the CM side anyways).

Your next step is not going to be as easy as simply including a certain POM I think. When you look at the DXA source code, the connection to DD4T is in the Tridion provider: https://github.com/sdl/dxa-web-application-java/tree/master/dxa-framework/dxa-tridion-provider

There is a POM there you can peek into, which defines the following DD4T dependencies:

    <!-- DD4T -->
    <dependency>
        <groupId>org.dd4t</groupId>
        <artifactId>dd4t-api</artifactId>
        <exclusions>
            <exclusion>
                <groupId>com.tridion.contentdelivery</groupId>
                <artifactId>*</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.dd4t</groupId>
        <artifactId>dd4t-core</artifactId>
        <exclusions>
            <exclusion>
                <groupId>com.tridion.contentdelivery</groupId>
                <artifactId>*</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.dd4t</groupId>
        <artifactId>dd4t-databind</artifactId>
        <exclusions>
            <exclusion>
                <groupId>com.tridion.contentdelivery</groupId>
                <artifactId>*</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.dd4t</groupId>
        <artifactId>dd4t-providers</artifactId>
        <exclusions>
            <exclusion>
                <groupId>com.tridion.contentdelivery</groupId>
                <artifactId>*</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
2

It's a good idea to re-use the XML serialization aspect of DD4T / DXA. I'd suggest to get the DD4T 2.0 version of the Compound Templates installer, https://github.com/dd4t/DD4T.TridionTemplates

You'll need to build it, and then look under the tools for the .bat file to upload the Compound Templates to Tridion. https://github.com/dd4t/DD4T.TridionTemplates/tree/master/tools/template-installer

Then, you can go into Template Builder and you will have the TBBs for producing DD4T XML.

Some advantages to using this approach is that they serialize everything for you (beware of the link levels) and also that in the future if you decide to use DD4T for any of your websites, you won't need to re-publish the content.

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.