I'm working on an implementation that has "configuration" components attached in page metadata (as component links) for things like navigation visibility, SEO fields - etc. This is so the configuration content may be localized, without having localizing the pages (instead of putting the fields in page meta); nothing new here.

I've set the link levels on the PT TBBs appropriately so the metadata JSON is being included when published. I have validated on the CD side that in the Page model object, I can grab the metadata fields map and from that map, retrieve the component attached as a component link.

At this point, I can see the are fields being populated in the "Component" object - which means the data was published in the JSON as I'd expect. I am wondering how I can deserialize the Component object into one of my classes - similar to what is done with the ViewModels in the CPs on the page?

What I've tried:

  • I've scanned through the DD4T-2 source code and am able to find where the deserialization is happening - but in order to deserialize via the DataBindFactory I need the raw source for the component.
  • I'm unable to grab the raw source for the component. I've scoured through the models and can't find any simple ways to achieve grabbing the JSON.

I'm really just looking to avoid populating the objects fields manually (via grabbing each field individually out of the component attached in metadata and setting my strongly typed objects fields). I could just write some code to retrieve the values and populate the object, but for each new field I'd rather update / maintain the POJO rather than the class responsible for the field population.

Note that we're on DD4T-2 (Java) 2.0.3.

Any input would be greatly appreciated.

1 Answer 1


looking at the ViewModelBase, is it possible to set setRawData to true and call the inherited getRawDataAsString() to grab the RAW component data?

@ViewModel (
        rootElementNames = {"joshsContent"},
        viewModelNames = {"JoshsStuff"},
        setComponentObject = true,
        setRawData = true)

public class JoshsStuff extends TridionViewModelBase {
  • Thanks Mark. I had this thought as-well, but the problem is I only have access to the Component object itself. Since the component is added in metadata, and is not a CP on the page - I can't grab the viewModel from the component presentation object like usual. Instead, I grab the metadata from the page - and retrieve the ComponentLinkField object (the component itself). Normally the viewModel is populated as a strongly typed obj (ie JoshsStuff class), but in this scenario I'm afraid it's not.
    – Josh Hebb
    Sep 20, 2016 at 23:13

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.