AEM as a Cloud Service SPA React | Nested Multifield Json is not rendering in model.json | Community
Skip to main content
May 31, 2023
Solved

AEM as a Cloud Service SPA React | Nested Multifield Json is not rendering in model.json

  • May 31, 2023
  • 1 reply
  • 1606 views

Hi,

 

I am using nested multifield in AEM SPA with react .When I am trying to access the <page url>.model.json, nothing is rendered. But, when I try to retrieve with component node path,<page-node-path>.model.json, then it returns the component json.

 

Please let me know how can I retrieve nested multifield values in page model.json

 

Multifield Node Structure:

 Page model.json:

Specific Component Model Json:

Code Snippet:

 

 

 

 

 

 

Thanks,

Divya 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Divya_13

Okay @divya_13 Got It now!

Can you please try writing a explicit getter method for this json array object(offices) and try?

 

This seems interesting issue 🙂


Hi  @iamnjain 

 

I am able to resolve this issue by adapting to SlingHttpServletRequest.class instead of Resource.class and added ComponentExporter.class and removed custom interface in adapters. I have added getter at class level.

Thank you for all your inputs.

 

1 reply

iamnjain
Community Advisor
Community Advisor
June 1, 2023

Hello @divya_13 

 

Can you please try to tweak your main component sling model code a bit, as below

In your Model Interface, extends it with ComponentExporter class from 

com.adobe.cq.export.json.ComponentExporter
 
and In you Model impl class, apart from CapabilityMapModel interface in adapters, add 
ComponentExporter as well, like below

adapters = { CapabilityMapModel.class,
ComponentExporter.class }

Do let me know, if it's resolve your issue. 🙂
Divya_13Author
June 1, 2023

Hi @iamnjain 

 

When I added both adapters, ComponentExporter.class and CapabilityMapModel.class, the first level values are also coming empty in page model.json.

iamnjain
Community Advisor
Community Advisor
June 1, 2023

Hello @divya_13 

 

I just now observed in your main sling model Impl class, you are using @JsonIgnore annotation on all three child resources ( multifields ), so that's the reason It's not appearing in your page json. Can you please try removing that annotation and build and see if it works?