4

Not able to bind Rich Text field to Model if I am embedding an ECL image in a RTF field. Getting below error:

Unable to map field 'description' to property of type 'Sdl.Web.Common.Models.RichText'. ---> Sdl.Web.Common.DxaException: No semantic mapping found between Schema 295 (http://www.sdl.com/web/schemas/core:ExternalContentLibraryStubSchemamm) and model type 'Sdl.Web.Common.Models.MediaItem' Sdl.Web.Common.DxaException: Unable to map field 'description' to property of type 'Sdl.Web.Common.Models.RichText'. ---> Sdl.Web.Common.DxaException: No semantic mapping found between Schema 295 (http://www.sdl.com/web/schemas/core:ExternalContentLibraryStubSchemamm) and model type 'Sdl.Web.Common.Models.MediaItem' at DynamicModule.ns.Wrapped_IRichTextProcessor_6356ea62ef3f4433b0f047b3f93feb12.ProcessRichText(String xhtml, Localization localization) at Sdl.Web.Tridion.Mapping.DefaultModelBuilder.MapFieldValues(IField field, Type modelType, Boolean multival, MappingData mapData) in D:\Repository\LocalDevstage27March\master\source code\web application\Sdl.Web.Tridion\Mapping\DefaultModelBuilder.cs:line 622 --- End of inner exception stack trace --- at Sdl.Web.Tridion.Mapping.DefaultModelBuilder.MapFieldValues(IField field, Type modelType, Boolean multival, MappingData mapData) in D:\Repository\LocalDevstage27March\master\source code\web application\Sdl.Web.Tridion\Mapping\DefaultModelBuilder.cs:line 653 at Sdl.Web.Tridion.Mapping.DefaultModelBuilder.CreateViewModel(MappingData mappingData) in D:\Repository\LocalDevstage27March\master\source code\web application\Sdl.Web.Tridion\Mapping\DefaultModelBuilder.cs:line 400 at Sdl.Web.Tridion.Mapping.DefaultModelBuilder.BuildEntityModel(EntityModel& entityModel, IComponent component, Type baseModelType, Localization localization) in D:\Repository\LocalDevstage27March\master\source code\web application\Sdl.Web.Tridion\Mapping\DefaultModelBuilder.cs:line 191 at Sdl.Web.Tridion.Mapping.DefaultModelBuilder.BuildEntityModel(EntityModel& entityModel, IComponentPresentation cp, Localization localization) in D:\Repository\LocalDevstage27March\master\source code\web application\Sdl.Web.Tridion\Mapping\DefaultModelBuilder.cs:line 144 at Sdl.Web.Tridion.Mapping.ModelBuilderPipeline.CreateEntityModel(IComponentPresentation cp, Localization localization) in D:\Repository\LocalDevstage27March\master\source code\web application\Sdl.Web.Tridion\Mapping\ModelBuilderPipeline.cs:line 100 at Sdl.Web.Tridion.Mapping.DefaultModelBuilder.BuildPageModel(PageModel& pageModel, IPage page, IEnumerable`1 includes, Localization localization) in D:\Repository\LocalDevstage27March\master\source code\web application\Sdl.Web.Tridion\Mapping\DefaultModelBuilder.cs:line 76

  • Please provide the error in detail from Site.Log. Also confirm if your model is registered in your <Module>AreaRegistration ? if not then register that first and check it again. – Sayantan Basu Mar 31 '17 at 5:47
  • Although I think Sayantan already provided the answer to your question, I'm wondering why you're using a custom build (given the file paths in the stack trace) and what that DynamicModule.ns.Wrapped_IRichTextProcessor line in the stack trace is about (I would expect DefaultRichTextProcessor there)? – Rick Pannekoek Mar 31 '17 at 7:14
2

I am assuming that you are using DXA Media Manager module and you have already created a Model for the Media Manager item, if not then add a Model in your project. Here is the sample for that;

[SemanticEntity(CoreVocabulary, EntityName = "ExternalContentLibraryStubSchema-mm", Prefix = "a", Public = true)]
public class MultiMediaModel : MediaManagerDistribution
{ 
}

And add entry for your Model in ModuleAreaRegistration.cs like;

RegisterViewModel(typeof(MultiMediaModel));

Let me know if this helps.

  • 1
    I would strongly recommend to use the Media Manager Module instead of "reinventing the wheel". – Rick Pannekoek Mar 31 '17 at 7:07
  • @RickPannekoek yes I agree. This is just a workaround. – Sayantan Basu Mar 31 '17 at 7:16
  • BTW: the example shows how to create a custom subclass of MediaManagerDistribution which is a View Model from the MM Module. So, it's not an alternative for the MM Module, nor does it add anything. I'm aware that a custom subclass is currently needed if (and only if) you're using retrofit mode: github.com/sdl/dxa-modules/issues/23 – Rick Pannekoek Mar 31 '17 at 7:21
  • @RickPannekoek Yes! Basically I am creating a subclass of MediaManagerDistribution and registering it. Actually I am using the same type of implementation in current application as well (without retrofit mode) because there we have added some additional field in metadata design of MM schema and I don't want to change anything in the default modle. I am just trying to understand is this approach not recommended ?? then may be I can change the approach. – Sayantan Basu Mar 31 '17 at 7:58
  • Creating your own subclass of MediaManagerDistribution with additional properties/methods/annotations is fine (indeed much better than changing the MM Module itself), but in the above example the subclass doesn't add any of those and hence is not needed. – Rick Pannekoek Mar 31 '17 at 8:17

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.