Esta conversación ha sido bloqueada debido a la inactividad. Cree una nueva publicación.
Nivel 1
Nivel 2
Iniciar sesión en la comunidad
Iniciar sesión para ver todas las insignias
Esta conversación ha sido bloqueada debido a la inactividad. Cree una nueva publicación.
Hi All,
We are trying to determine if there is a way to override the node name while exposing the model JSON. The properties for JSON can be controlled by exporter but not the node name itself. For example following is page structure
page
jcr:content
parsys
component (node has its properties)
component_xxx (node has its properties)
component_yyy (node has its properties)
Component has its exporter implemented. Now when we try to get data as page.model.json we get the node names in response as component, component_xxx, component_yyy.
Is there way to change this in Sling Model Exporter JSON output, as by default AEM generates random node names for same component dragged in page, we wanted to expose a meaningful name as part of JSON output (We are trying to customize content fragment JSON output). Let me know if there is way or which direction which should look into.
Thanks,
Sandeep
¡Resuelto! Ir a solución.
Vistas
Respuestas
Total de me gusta
When testing localhost:4502/content/we-retail/us/en/user.model.json, I get a JSON model. But I don't think that this page is backed by an explicit Sling model, but rather by a default implementation.
You can always implement a custom model and then choose the names yourself.
Jörg
Vistas
Respuestas
Total de me gusta
When testing localhost:4502/content/we-retail/us/en/user.model.json, I get a JSON model. But I don't think that this page is backed by an explicit Sling model, but rather by a default implementation.
You can always implement a custom model and then choose the names yourself.
Jörg
Vistas
Respuestas
Total de me gusta
Thanks Jörg
It seems the AEM Core Components has Page Model implementation. This has a method
private <T> Map<String, T> getChildModels(@Nonnull SlingHttpServletRequest slingRequest,
@Nonnull Class<T> modelClass) {
Map<String, T> itemWrappers = new LinkedHashMap<>();
for (final Resource child : slingModelFilter.filterChildResources(request.getResource().getChildren())) {
itemWrappers.put(child.getName(), modelFactory.getModelFromWrappedRequest(slingRequest, child, modelClass));
}
return itemWrappers;
}
We can tweak this to change child.getName(), One observation I had is this depends on JCR structure, but if our nodes are more nested control goes to modelFactory.getModelFromWrappedRequest(slingRequest, child, modelClass)call, this is part of AEM out of the box bundles. And we need to look into to tweak this.
Regards,
Sandeep
Vistas
Respuestas
Total de me gusta
the modelFactory interface belongs to sling, and the only implementation I have on my 6.4 instance is org.apache.sling.models.impl.ModelAdapterFactory (sling-org-apache-sling-models-impl/ModelAdapterFactory.java at master · apache/sling-org-apache-slin... ). Maybe you can dig deeper there.
Jörg
Vistas
Respuestas
Total de me gusta
Vistas
me gusta
Respuestas
Vistas
me gusta
Respuestas