2

We have created a custom page model in order to get the metas of the SG in our page. The PageModelData contains the values in the field metadata. But when mapping to our customPageModel class, we don't get this information mapped. We are using Java version of DXA 2.0

@Data
@SemanticEntities({
        @SemanticEntity(entityName = "WebExtraPage", vocabulary = SDL_CORE),
        @SemanticEntity(entityName = "StructureGroupProperties", vocabulary = SDL_CORE, prefix = "sgp")})
public class WebExtraPageModel extends DefaultPageModel {

    @JsonProperty("Metadata")
    protected Map<String, String> metadata = new HashMap<>();
    @SemanticProperty("sgp:brand")
    private String brand;
}

We have tried both approches, but none works. We have read the documentation but it's uncomplete and the class doesn't exist.

This is the debugging value of the structures when building the page Model (buildPageModel)enter image description here

3
  • Can you check if the structure group metadata is actually published together with your page ? I believe there are some specific template building blocks that need to be set or configured in order to add this structure group metadata - check for example this model builder (in the DXA 2 templates code - github.com/sdl/dxa-content-management/blob/master/…) Oct 10, 2018 at 7:21
  • Information is in the pageModelData, but it doesnt' map it to the pageModel
    – tfinez
    Oct 10, 2018 at 7:57
  • could you also check if you republished the DXA settings page. Can you also try to remove the prefix in the mapping attribute for brand ? Oct 10, 2018 at 11:24

1 Answer 1

1

It seems your Page doesn’t have a Metadata Schema (pageModelData.SchemaId is null).

DXA Semantic mapping needs a Schema. Can you try if it works if you let your Page have a Metadata Schema which deFines the field “brand” (as an optional field)?

UPDATE

The DXA 2.0 semantic mapping will automatically pick up inherited metadata Schemas, but there is a defect that semantic mapping is skipped if the Page has no metadata Schema itself. This will be fixed in a future release.

4

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.