2

At this moment I have a DD4T 2.2 .NET webapplication which uses the DXA Model Service (SDL Web 8.5). All my fields are working, except for the Multimedia fields.

The image property in the ViewModel object is null:

enter image description here

My model looks like this:

enter image description here

But the item is also not available in the Component object:

enter image description here

Model Service calls:

The following calls are done from the webapplication (captured by Fiddler):

enter image description here

The response of the PageModel call can be found here (most of the image properties are null). The response of the EntityModel can be found here (image properties are filled).

Rick found out that the Entity Model response is in DXA R2 format (which is a bug?).

The Page Model JSON on the CM-side (using Preview functionality) looks as follows:

{
   "Id":"128733",
   "Title":"Home",
   "PageTemplate":{
      "Id":"128931",
      "Title":"Standaard",
      "FileExtension":"html",
      "RevisionDate":"2019-03-19T14:05:57.12"
   },
   "StructureGroupId":"16859",
   "UrlPath":"/index",
   "Meta":{
      "twitter:card":"summary",
      "og:title":"Home",
      "og:type":"article",
      "og:locale":"en-US",
      "og:image":"tcm:135-128756",
      "description":"Home"
   },
   "Regions":[
      {
         "Name":"Main",
         "Entities":[
            {
               "Id":"128938-128930"
            }
         ],
         "MvcData":{
            "ViewName":"Main"
         }
      }
   ],
   "MvcData":{

   },
   "XpmMetadata":{
      "PageID":"tcm:135-128733-64",
      "PageModified":"2019-03-20T18:33:20.063",
      "PageTemplateID":"tcm:135-128931-128",
      "PageTemplateModified":"2019-03-19T14:05:57.12"
   }
}

For testing I added the component as Embedded CT on the page, the JSON on CM-side for that page looks like this (multimedia values are filled):

{
  "Id": "148023",
  "Title": "Home",
  "PageTemplate": {
    "Id": "148001",
    "Title": "Standaard",
    "FileExtension": "html",
    "RevisionDate": "2019-03-27T07:10:51.883"
  },
  "StructureGroupId": "21456",
  "UrlPath": "/index",
  "Meta": {
    "twitter:card": "summary",
    "og:title": "Home",
    "og:type": "article",
    "og:locale": "en-US",
    "og:image": "tcm:155-147994",
    "description": "Home"
  },
  "Regions": [
    {
      "Name": "Main",
      "Entities": [
        {
          "Id": "147995",
          "ComponentTemplate": {
            "Id": "147998",
            "Title": "Nieuws",
            "RevisionDate": "2019-03-27T09:30:16.433",
            "OutputFormat": "HTML Fragment",
            "Metadata": {
              "controller": "News",
              "action": "ComponentModel",
              "view": "Index"
            }
          },
          "Folder": {
            "Id": "21494",
            "Title": "Nieuws"
          },
          "Content": {
            "title": "Titel",
            "image": {
              "$type": "EntityModelData",
              "Id": "147994",
              "ComponentTemplate": {
                "Id": "147957",
                "RevisionDate": "0001-01-01T00:00:00"
              },
              "Folder": {
                "Id": "21494",
                "Title": "Nieuws"
              },
              "BinaryContent": {
                "Url": "/Preview/Images/logo_tcm155-147994.png",
                "FileName": "logo.png",
                "FileSize": 28332,
                "MimeType": "image/png"
              },
              "SchemaId": "147781"
            },
            "introduction": "Introduction text",
            "paragraphs": {
              "$type": "ContentModelData",
              "title": "Paragraaf 1",
              "body": {
                "$type": "ContentModelData",
                "body": {
                  "$type": "RichTextData",
                  "Fragments": [
                    "\n                <p>Bodytext</p>\n              "
                  ]
                }
              }
            }
          },
          "MvcData": {
            "ControllerName": "News",
            "ActionName": "ComponentModel",
            "ViewName": "Index"
          },
          "XpmMetadata": {
            "ComponentID": "tcm:155-147995",
            "ComponentModified": "2019-03-27T06:54:07.757",
            "ComponentTemplateID": "tcm:155-147998-32",
            "ComponentTemplateModified": "2019-03-27T09:30:16.433",
            "IsRepositoryPublished": false
          },
          "SchemaId": "147976"
        }
      ],
      "MvcData": {
        "ViewName": "Main"
      }
    }
  ],
  "MvcData": {},
  "XpmMetadata": {
    "PageID": "tcm:155-148023-64",
    "PageModified": "2019-03-27T08:25:19.72",
    "PageTemplateID": "tcm:155-148001-128",
    "PageTemplateModified": "2019-03-27T07:10:51.883"
  }
}

The DXA Model Service returns for modelType=DD4T for this page this result (multimedia value is null).

  • 2
    The JSON coming from Model Service which you show is DXA R2 JSON. However, a DD4T Web Application will retrieve DD4T JSON. You should have a look at how that DD4T JSON looks like. – Rick Pannekoek Mar 19 at 18:25
  • 1
    Can you try with [LinkedComponentField(IsMetadata = true, FieldName = "image")]? – Velmurugan Mar 19 at 23:08
  • @RickPannekoek, the Model Converter of the DXA Model service has converted the JSON because of the parameter 'modelType=DD4T' (you can see it in screenshot). @ Velmurugan, your suggestion gives the same result. – Peter van der Lugt Mar 20 at 7:52
  • @Velmurugan, is there a reason you suggest to use 'IsMetadata = true'? – Peter van der Lugt Mar 20 at 9:35
  • 1
    Interesting. The Page Model JSON is DD4T JSON, the Entity Model JSON is not. – Rick Pannekoek Mar 20 at 19:41
2

The issue is now reported on GitHub. I found out that there are multiple issues when working with the DXA Model Service together with DD4T. There is an issue related to keywords and there seems also to be an issue with the DD4T.Providers.DxaModelService package, when retrieving Component Presentations with the methods: ComponentPresentationFactory.GetComponentPresentation (throws an error) and ComponentPresentationFactory.GetComponentPresentations (most of the fields are null).

Because of all the articles about the possibility to use the Model Service together with DD4T and the fact that it is supported by SDL I thought it would be a good approach. Now it seems to me that I am the first one ever using this approach on a 'real' project and there is still some work to do.

Since we are at the beginning of our project and facing these kind of issues we decided to stop using this approach en go for the approach DD4T together with the Content Service by using the DD4T.Providers.SDLWeb8.5.CIL package instead of using DD4T.Providers.DxaModelService.

The reason I choose for the DD4T + DXA Model Service approach is mostly because of this article. I was charmed by the promised performance gain. I also share the vision that I prefer a Framework (DD4T) over an customizable webapplication (which DXA is at this moment). When DXA Core is there (the framework) I will surely migrate the application.

  • Thanks for the feedback and sorry for all the hurdles you hit. I think you’re right that you are one of the first to try this configuration in the field. – Rick Pannekoek Mar 29 at 8:46
  • 1
    BTW: in general, the DD4T support in DXA Model Service is intended for migration of existing DD4T Web Apps, but this sounds like you were considering it for a new implementation? Could you elaborate on the requirements and the reasoning behind choosing a DD4T Web App vs. a DXA Web App or “the Content Service approach” ? – Rick Pannekoek Mar 29 at 8:54
  • @RickPannekoek, good questions, I updated my question ;-) – Peter van der Lugt Mar 29 at 9:27
  • Thanks, that helps to define the future of DXA. Note that DXA is a Framework (+ example Web App) too. Would be nice to understand what people consider too limiting at the moment. – Rick Pannekoek Mar 29 at 11:22
1
+50

Assuming that in your scenario, your View Model represents a Component Presentation which is part of a Page, we can focus on the Page Model JSON (which is correctly DD4T JSON).

There is a problem with this Page Model JSON: you can see that the “image” field is a MultiMedia link field and the JSON includes the expanded linked MM Component. However the Multimedia property of the expanded MM Component is null.

This is potentially a defect in the R2->DD4T conversion in the DXA Model Service.

Can you provide the DXA R2 Page Model JSON as generated by the CM System (that is: do a CM Preview on the Page)?

  • I added the requested JSON. The Page Template has the 'Render Page Content' TBB assigned. – Peter van der Lugt Mar 22 at 9:00
  • Ok, so apparently the Page contains a DCP which isn’t expanded on CM-side, but in the Model Service. Might be part of the issue. Could you try with an embedded CP? – Rick Pannekoek Mar 22 at 10:08
  • when I add an MultiMedia component via an embedded schema, the MultiMedia property is also null. When I add a it via an Component Link, the Model Service throws a 500 error. – Peter van der Lugt Mar 22 at 13:17
  • As addition on my last comment, when I do the same call with parameter modelType=R2 then the call doesn't fail. So there seems to be an issue in the Model Service indeed. – Peter van der Lugt Mar 22 at 13:50
  • For clarity: I meant using an embedded CP (so not a dynamic CT) and then check how the DXA Page Model generated by CM looks (CM Preview). Next question would be how the Page Model generated by MS looks. – Rick Pannekoek Mar 22 at 14:45

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.