In order to avoid translating pages we've added a linked component in our page metadata.

enter image description here

I've created a custom page model:

@SemanticEntity(entityName = "MyPageModel", vocabulary = SDL_CORE, public_ = true)
@EqualsAndHashCode(callSuper = true)
public class MyPageModel extends DefaultPageModel {

    public MyLinkedPageMetaData myLinkedPageMetaData;


I've registered this in my initializer:

@RegisteredViewModel(viewName = "MyPageTemplate", modelClass = MyPageModel.class)

I've create the model for the linked component schema:

@SemanticEntity(entityName = "MyLinkedPageMetaData", vocabulary = SDL_CORE, public_ = true)
@EqualsAndHashCode(callSuper = true)
public class MyLinkedPageMetaData extends AbstractEntityModel{  
    public String pageTitle;

I'm trying to access this in my view via:

<jsp:useBean id="pageModel" type="com.client.dxawebapp.model.page.MyPageModel" scope="request" />


However the value is never written out, it's just blank.

When I write out ${pageModel.meta} I see "myLinkedPageMetaData=''".

Previewing the page I see:

"Metadata": {
  "nonTranslatedTitle": "Test title",
  "myLinkedPageMetaData": {
    "$type": "EntityModelData",
    "Id": "20953",
    "ComponentTemplate": {
      "Id": "10581",
      "RevisionDate": "0001-01-01T00:00:00"
    "Folder": {
      "Id": "1058",
      "Title": "Page Metadata Components"
    "Content": {
      "pageTitle": "Page title in linked component",
    "SchemaId": "20952"

My question is: how can I obtain the values in my linked component in DXA 2.0 Java?

Note: The same approach works fine in DXA 2.0 .Net.

To add with it the template output of the page contains tcm id for that component link field but it got empty in front end DXA java app. tried with text field to have tcm id it behaves same.

enter image description here

enter image description here

And there is sperate metadata in json which we couldn't use it in page model from template output its having template as "Generate Data Presentation" not sure where its configured to use that.enter image description here

  • What is the root element name of your linked Component? The semantic entity name of MyLinkedPageMetadata should match the root element name. Oct 8 '20 at 19:25
  • Furthermore, the MyLinkedPageMetadata View Model should also be registered. Oct 8 '20 at 19:28
  • Thanks Rick. The root element name is indeed "myLinkedPageMetaData" (same as the semantic entity name). Do you have an example of how the MyLinkedPageMetadata model should be registered please? I tried this @RegisteredViewModel(modelClass = MyLinkedPageMetadata.class) Oct 8 '20 at 19:30
  • The semantic entity name is “MyLinkedPageMetaData” (initial capital) is that exactly the same as the root element name? Note that if the semantic entity name is exactly the same as the class name, the @SemanticEntity annotation is redundant. Oct 8 '20 at 19:34
  • Your way to register the View Model looks fine to me. Oct 8 '20 at 19:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.