Expand my Community achievements bar.

SOLVED

AEM 6.5 SPA React | Nested Multifield Not working

Avatar

Level 7

Hi All,

 

I am using nested multifield in AEM6.5 SPA with react. It is not rendering in model json.

Any help is highly appreciated.

 

Thanks,

Pradeep

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

SPA
1 Accepted Solution

Avatar

Correct answer by
Community Advisor

It seems like a particular case; you need to troubleshoot to resolve the issue.

Did you create a separate sling model to read the values of nested multifield from JCR? If yes, I would check whether the sling model has the ComponentExporter adapter and Exporter annotation for exporting the values via the model.json framework.

Lastly, I would start checking for any errors in the logs, and if there are no NPE or other errors, run the AEM in debug mode, add breakpoints in the sling model, and observe the values read from the JCR.

View solution in original post

11 Replies

Avatar

Community Advisor

Hi @pradeepdubey82 

 

How are the values persisting for nested multifield in JCR? If you're persisting the property values in node hierarchy (child nodes for nested multifield values), then you've to read them in the Component Sling Model using the Child Resource From Request Injector. 

Avatar

Level 7

Yes values are persisting in jcr also loading in cq dialog. I am using childresource annotation for the element in sling model. 

Still it is not rendering in model json. 

 

Thanks,

Pradeep

Avatar

Community Advisor

Ok. Question: Other properties of component except the nested multifield are showing up in model.json response? 

Avatar

Correct answer by
Community Advisor

It seems like a particular case; you need to troubleshoot to resolve the issue.

Did you create a separate sling model to read the values of nested multifield from JCR? If yes, I would check whether the sling model has the ComponentExporter adapter and Exporter annotation for exporting the values via the model.json framework.

Lastly, I would start checking for any errors in the logs, and if there are no NPE or other errors, run the AEM in debug mode, add breakpoints in the sling model, and observe the values read from the JCR.

Avatar

Community Advisor

Hi @pradeepdubey82 

 

Can you please share the below details to debug further?

  1. Your model code
  2. The JCR node - on how the data is being stored
  3. If there is any error in the log

Mainly the issue happens while injecting, as you have mentioned that you can see the values in the JCR.

 

Thanks,
Kiran Vedantam.

Avatar

Level 7

Hi Kiran,

 

I am sharing below for reference.

JCR structure 

 

pradeepdubey82_0-1674190772003.png

 

Sling models

pradeepdubey82_1-1674190823667.pngpradeepdubey82_2-1674190848137.png

pradeepdubey82_3-1674190866095.png

Model json

pradeepdubey82_4-1674190932801.png

CQ dialog 

pradeepdubey82_5-1674191019411.png

 

pradeepdubey82_6-1674191051900.pngpradeepdubey82_7-1674191072859.png

 

Avatar

Level 4

Hi @pradeepdubey82 ,

 

Try to inject like this 

	@Inject
	@Via("resource")
	@Named("accordians")
	private List<Resource> accordians;

 

Try to adapt each resource to AccordionModal

	public List<AccordionModal> getAccordionModalList() {
		List<AccordionModal> AccordionModalList = new ArrayList<>();
		if (null != accordions) {
			accordions.forEach(i -> AccordionModalList.add(i.adaptTo(AccordionModal.class)));
		}
		return AccordionModalList;
	}

 

Do the same thing for AccordionBulletPointModal.

Avatar

Community Advisor

Hi @pradeepdubey82 

 

AccordionModel & AccordionBulletPointModel are missing the Exporter annotation to export the values via Sling Model Exporter framework. 

 

Add the following annotation to both the sling models 

@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION)