Sling model exporter
Hi All,
Hope you all are fine.
Although, I don’t have any specific problem related to exporter but would like to understand best approach while serving content from AEM to some react component.
For example:
We have a ABC component in which all labels should be served from AEM and all dynamic logic should be written in react component. We have multiple similar components to implement.
It is not a SPA application.
so, in our AEM component HTL, we simply write a container div with some data attribute
<div data-component="ABC"></div>.
Now, How AEM should provide all dialog labels to REACT.
- Through Sling model exporter
- Any other way (would like to learn from experts here).
SLING MODEL:
@Model(adaptables = SlingHttpServletRequest.class, resourceType = ABC.RESOURCE_TYPE, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
@3484101(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION)
public class ABC {
protected static final String RESOURCE_TYPE = "mysite/components/abc";
@ValueMapValue(name = "title")
private String title;
@ValueMapValue(name = "subtitle")
private String subtitle;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getSubtitle() {
return subtitle;
}
public void setSubtitle(String subtitle) {
this.subtitle = subtitle;
}
}
Using, approach 1,
1) Should we create one sling model exporter for each component?
2)
example URL for ABC component:
/content/experience-fragments/mysite/us/en/test/master/jcr:content/root/abc.model.json
If we provide this URL to react (ui.frontend), can it be accessed from REACT without any further configurations needed like allowing "model" selector in config manager or at dispatcher level?
3) Is it necessary to create single exporter for each component or we can create a centralized exporter that can be used for all similar components.
4) Any better and optimized way to manage such scenarios?
Thank you in advance.
Regards,
AP


