2

We are migrating from DXA 1.2 to DXA 1.5. As part of that we had set up personalized modules and initializing the modules accordingly using ModuleInitializer with that specific area name.

For some reasons, we are not getting the embedded Components like images on Footer Schema.

In moduleinitializer, we had registered the Footer View as well as Image model separately.

Can someone please help us.

Below is the code of ModuleInitializer

//Page Model
@RegisteredViewModel(viewName = "PlainCodeTextPV", modelClass = PageModelImpl.class),
//@RegisteredViewModel(viewName = "CDAResponsivePV", modelClass = PageModelImpl.class),
//@RegisteredViewModel(viewName = "CDARobotPV", modelClass = PageModelImpl.class),
@RegisteredViewModel(viewName = "ResponsivePV", modelClass = PageModelImpl.class),
@RegisteredViewModel(viewName = "GeneralPage", modelClass = PageModelImpl.class),
@RegisteredViewModel(viewName = "IncludePage", modelClass = PageModelImpl.class),
@RegisteredViewModel(viewName = "RedirectPage", modelClass = PageModelImpl.class),

@RegisteredViewModel(modelClass = Image.class),

@RegisteredViewModel(viewName = "Footer", modelClass = RegionModelImpl.class),    

@RegisteredViewModel(viewName = "FooterCV", modelClass = Footer.class),
})


public class CoreModuleInitializer extends AbstractInitializer {
@Override
protected String getAreaName() {
    System.out.println("Inside Area Name:: Core" );
    return "Test";
    }
}

======== Model Java

@SemanticEntity(entityName = "Footer", vocabulary = SDL_CORE, prefix = "tri", public_ = true) public class Footer extends AbstractEntityModel {

@JsonProperty("Heading")
@SemanticProperty("tri:heading")
private String heading;

@JsonProperty("ContactUsLink")
@SemanticProperty("tri:contactUsLink")
private Link contactUsLink;

@JsonProperty("AdditionText")
@SemanticProperty("tri:additionText")
private RichText additionText;

@SemanticProperty("tri:socialMediaIcons")
@JsonProperty("SocialMediaIcons")
private List<SocialMediaSharing> socialMediaIcons;

@SemanticProperty("tri:footerLinks")
@JsonProperty("FooterLinks")
private List<Link> footerLinks;

@JsonProperty("ChairImage")
@SemanticProperty("tri:chairImage")
private Image chairImage;

@JsonProperty("SiteMap")
@SemanticProperty("tri:siteMap")
private SiteIndexContent siteMap;

public SiteIndexContent getSiteMap() {
    return siteMap;
}

public void setSiteMap(SiteIndexContent siteMap) {
    this.siteMap = siteMap;
}

public Image getChairImage() {
    return chairImage;
}

public Link getContactUsLink() {
    return contactUsLink;
}

public List<Link> getFooterLinks() {
    return footerLinks;
}

public String getHeading() {
    return heading;
}

public List<SocialMediaSharing> getSocialMediaIcons() {
    return socialMediaIcons;
}

public void setChairImage(Image chairImage) {
    this.chairImage = chairImage;
}

public void setContactUsLink(Link contactUsLink) {
    this.contactUsLink = contactUsLink;
}

public void setFooterLinks(List<Link> footerLinks) {
    this.footerLinks = footerLinks;
}

public void setHeading(String heading) {
    this.heading = heading;
}


public RichText getAdditionText() {
    return additionText;
}

public void setAdditionText(RichText additionText) {
    this.additionText = additionText;
}

}

@SemanticEntity(entityName = "ImageObject", vocabulary = SDL_CORE, prefix = "tri", public_ = true) //@ToString @Slf4j public class Image extends MediaItem {

@SemanticProperty("tri:name")
@JsonProperty("AlternateText")
@Getter
@Setter
private String alternateText;

/**
 * {@inheritDoc}
 */
@Override
@JsonIgnore
public boolean isImage() {
    return true;
}

..... .... }

6
  • Did you know the latest release of DXA is 1.6, if you are currently busy migrating, you might as well make sure you are migrating to the latest? The changes between 1.2 and 1.6 on the ModuleInitializer all come down to the changes in the AbstractInitializer, maybe it is useful if you edit your question and add the code of your 1.2 ModuleInitializer and the current one so it is clear what changes you have made? Nov 14, 2016 at 7:03
  • Thanks Bart for the response. i had corrected my question by adding the code.
    – Suresh
    Nov 14, 2016 at 15:01
  • Also we had spent a lot of time in bringing DXA 1.5 sample code up. Not sure if we can make the changes now. So would like to stick with DXA 1.5 for now.
    – Suresh
    Nov 14, 2016 at 15:02
  • Can you describe the problem more specifically? How does the problematic View Model look? Nov 14, 2016 at 18:53
  • Added the models in the question
    – Suresh
    Nov 14, 2016 at 20:37

1 Answer 1

1

We found the root cause for the issue.

The problem was in the way the our custom module was initialized. Namely, the SemanticMapper was not called on the model inside Emerald module. We added the necessary code to registerEntitites() in the EmeraldInitializer class.

@org.springframework.context.annotation.Configuration @ModuleInfo(name = "Emerald module", areaName = "Emerald", description = "Emerald DXA module which contains basic views") public class EmeraldCoreModuleInitializer extends AbstractInitializer { @Override protected String getAreaName() { return "Emerald"; }

@Autowired
private SemanticMappingRegistry semanticMappingRegistry;
@PostConstruct
private void registerModels() {
    semanticMappingRegistry.registerEntities(getClass().getPackage().getName());
}

}

Great thanks to @'Mihai Cădariu' for helping in resolving this issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.