Invalid recursion selector value 'model'
Cannot serve request to /content/demo/us/en/home/jcr:content/root/responsivegrid/testrender.model.json in org.apache.sling.servlets.get.DefaultGetServlet.
FYI:
AEM 6.5
ui.frontendmodule="angular"
I am working on an AEM spa project using angular as the frontend module.
I am facing the above problem for each component, AEM dialog values are not reflecting on the save of the dialog, if we are observing in the browser network it's giving the above model error. Only on a refresh of the page values are displaying on the screen.
Please help me to resolve this problem.
Requirement:
I have to create almost 80 custom components in our project, If I started to write a model class for each component then I will end up creating 80 model classes I cannot write 80 model classes to make reflect on the save of each component.
Please suggest to me how to resolve this problem !!
Note:
I am using JSON editor in my AEM component to store data as JSON and read data directly into the Angular component to bypass the slingModel. (No need for Sling Model in this case)
Awaiting your response.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @shyamasundar-ks ,
As per my understanding you need to create the Sling Model and do the following-
1. Implement the ComponentExporter interface from your class.
2. Define getExportedType() method in Sling Model and return resource type from the above method.
3. inside Model annotation parameters
a. Change adapter to SlingHtttpservletRequest.class from Resource.class
b. adapter = ComponentExporter.class
c. resource = <RESOURCE-TYPE-COMPONENT>
4. Add Exporter annotation with extension as 'model' and name as "jackson"
You can find sample code here - https://github.com/riteshmittal/spa-code
Hi @shyamasundar-ks ,
As per my understanding you need to create the Sling Model and do the following-
1. Implement the ComponentExporter interface from your class.
2. Define getExportedType() method in Sling Model and return resource type from the above method.
3. inside Model annotation parameters
a. Change adapter to SlingHtttpservletRequest.class from Resource.class
b. adapter = ComponentExporter.class
c. resource = <RESOURCE-TYPE-COMPONENT>
4. Add Exporter annotation with extension as 'model' and name as "jackson"
You can find sample code here - https://github.com/riteshmittal/spa-code
Thanks, Ritesh_M: for the reply, I have followed your videos on youtube, even I am also one of the subscribers of your channel
In my use case need to write sling-model for each component i.e for 80 custom components need to write 80 sling models now?
Because of using JSON-editor in my AEM components, I will get JSON data directly i.e I can access directly stored page dialog JSON data in angular using {{}} it's working fine for me. Now no need of writing sling-model to export JSON data in my case, cant we skip this sling-model or can't we write one generic sling-model to export dialog data as JSON instead of writing an individual sling-model?
Awaiting your response.
Views
Replies
Total Likes
Hi @shyamasundar-ks,
Please note that the selector "model" in the JSON path is because of the selector of @Exporter annotation(org.apache.sling.models.annotations.Exporter)whose default value is model (to expose the component data/Sling Model using that selector)
Now that you are not using Sling model/Exporter + accessing the path using model selector, you are getting "Invalid recursion selector value model"
Recommendation is to use Sling Model with Exporter framework to expose component data. If you are following alternate means, use the respective JSON path as is to read from Frontend.
Views
Likes
Replies