3

I have tried to define a model using MediaItem class(see Example below) but not working. I know how to do it using YouTubeVideo or embeded video

Also, When I extract MediaItem.java abstract class the mp4 mime type is not defined(MimeUtils.java)

Can you please provide the solution or existing example ?

Ex:

@JsonProperty("video")
@SemanticProperty("gv:video")
private MediaItem video;

public MediaItem getvideo() {
    return video;
}

public void setvideo(MediaItem video) {
    this.video = video;
}

@Override
public String toString() {
    return "GenericVideoLink [video=" + video + ", altText=" + altText
            + ", links=" + link + "]";
}   

Error:

[3/22/17 16:59:08:809 EDT] 0000006e SystemOut     O 16:59:08.809       [WebContainer : 0] ERROR c.s.w.c.i.m.ViewModelRegistryImpl - Cannot determine entity type for semantic schema names: '[http://www.sdl.com/web/schemas/core:DefaultMultimediaSchema]'. Please make sure that an entry is registered for this view name in the ViewModelRegistry.
[3/22/17 16:59:08:809 EDT] 0000006e SystemOut     O 16:59:08.809 [WebContainer : 0] DEBUG c.s.w.t.mapping.EntityBuilderImpl - Creating entity for component: tcm:650-178646
[3/22/17 16:59:08:829 EDT] 0000006e SystemOut     O 16:59:08.827 [WebContainer : 0] ERROR c.s.w.c.controller.PageController - Exception while processing request for: /dev/homebanner.html
java.lang.NullPointerException: null
   at com.sdl.webapp.common.impl.mapping.SemanticMapperImpl.createInstance(SemanticMapperImpl.java:51) ~[dxa-common-impl-1.5.0.jar:1.5.0]
   at com.sdl.webapp.common.impl.mapping.SemanticMapperImpl.createEntity(SemanticMapperImpl.java:97) ~[dxa-common-impl-1.5.0.jar:1.5.0]
   at com.sdl.webapp.tridion.mapping.EntityBuilderImpl.createEntity(EntityBuilderImpl.java:298) ~[dxa-tridion-provider-1.5.0.jar:1.5.0]
   at com.sdl.webapp.tridion.mapping.EntityBuilderImpl.createEntity(EntityBuilderImpl.java:278) ~[dxa-tridion-provider-1.5.0.jar:1.5.0]
   at 

2 Answers 2

3

Based on the error message, it seems that your MM Component for the Video is based on the Default MM Schema.

DXA Semantic Mapping tries to find a View Model type which is associated to the CM Schema through semantics on the Schema and the View Model types you have registered.

A Schema like "Default MM Schema" does not have specific semantics (it can be used for all kinds of binary media or documents), but you can create a generic Media Item View Model type for it:

  • Create a sublass of MediaItem (like in Harald's example)
  • Either call the class DefaultMultimediaSchema or put a @SemanticEntity(entityName="DefaultMultimediaSchema",vocabulary=SDL_CORE) annotation on the class.
  • Ensure the class is registered using a @RegisteredViewModel annotation on your Module Initializer

If you want to use specific View Model Types for specific types of MM Components (like the DXA Core Module: Image, YouTubeVideo and Download), you will have to use different MM Schemas on CM-side. It is (currently) not possible to associate View Model types with Multimedia Types on CM-side.

For clarity: the MIME type mapping in class MediaItem is only used to generate a (Font Awesome) icon class based on MIME type.

2

What error do you get exactly.

When implementing a viewmodel for a media item, you usually extend the MediaItem class with your custom class.

This custom class contains all semantic properties that you have defined in your multimedia schema, in in this custom class, you can also specify how to render your video, by implementing the different toHtmlElement functions. So, you would end up with a class like this

public class Mp4Video extends MediaItem {

//your custom semantic properties here 


@Override
public HtmlElement toHtmlElement(String s) throws DxaException {
    //return html to render video
}

@Override
public HtmlElement toHtmlElement(String s, double v, String s1, int i) throws DxaException {
    //return html to render video
}

@Override
public HtmlElement toHtmlElement(String s, double v, String s1, int i, String s2) throws DxaException {
    //return html to render video
}
}
6
  • Added the error details Commented Mar 23, 2017 at 13:40
  • Thanks for your rapid response Harald Hoffelinck but am not very clear. please see the below my model class. Can you please let me know, what need be change in my model ? //This is my parrent class refrence to my video class @JsonProperty("video") @SemanticProperty("b:video") private GenericVideoLink video; public class GenericVideoLink extends AbstractEntityModel { @JsonProperty("video") @SemanticProperty("gv:video") private MediaItem video; public MediaItem getvideo() { return video; } public void setvideo(MediaItem video) { this.video = video; } } Commented Mar 23, 2017 at 14:04
  • based on the erorr you added, it looks like you need to define a model mapping in your custom dxa module. It looks very similar to the question asked here : tridion.stackexchange.com/questions/15246/… Commented Mar 23, 2017 at 14:22
  • Yes I agree. That was my question, May I know how do I define a model mapping for video(mp4 or mpeg) field in my custom dxa module ? As mp4 is not supported in dxa Commented Mar 23, 2017 at 14:38
  • As mp4 mime type is not defined in dxa (java) Commented Mar 23, 2017 at 14:46

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.