Hi All,
We have requirement where we will have get all the products, accessories, and other information to the products. We are using tags and would like to use queries to get all the info and store in json format to cache in dispatcher.
I can do this in AEM servlet where we can write all the business logic, generate JSON when we request servlet. But calling servlet from sling model is not good idea. could you please advise what are the options we have to generate JSON and cache in dispatcher?
Solved! Go to Solution.
Views
Replies
Total Likes
yeah, your ajax call will go to the servlet which returns json.
https://www.w3schools.com/js/tryit.asp?filename=tryjs_ajax_first
You can generate json and cache at the dispatcher and use front end logic to generate presentation using this json.
@arunpatidar , we are thinking to write business logic in servlet so that we can cache at the servlet json at dispatcher level but the question is how can we refer the sling servlet in Sling Model level to read the json and pass data back to sightly.
Are you saying to make a call to servlet from front end (javascript directly ) without interacting with sling Model?
Hi @SonuR1
Yes, you can directly make a request from front end to servlet without interacting with sling Model.
Small business logic can also be done at front end if needed and the other backend configuration can also be exposed as data-attribute in HTL using sling model
@arunpatidar you mean, make Ajax call and get response in javascript and pass the data from javascript to sightly ?
would be great if you can share any examples code snippets.
yeah, your ajax call will go to the servlet which returns json.
https://www.w3schools.com/js/tryit.asp?filename=tryjs_ajax_first
Views
Likes
Replies
Views
Likes
Replies