SDI with SPA component | Community
Skip to main content
Level 2
January 23, 2020
Solved

SDI with SPA component

  • January 23, 2020
  • 2 replies
  • 2395 views

All data to react (frontend) comes via .model.json, which contains all info of the page. If I want to have a component that should not be cached, rather gets called on every request and then .model.json should always gets updated content, how we can do that ? 

Use case is : On each request, I want to check whether the user is allowed for particular action and then pass that true/false to the model.json so that react does not render the component (want to achieve CUG at component level )

 

Do not wish to create a servlet as this info is required before page rendering and ajax call would delay rendering.

 

Also, can we still add HTL on component in AEM that been mapped with React so that data attributes can be read by react component during rendering ? And then use SDI on that component ?

 

Any pointers ? @joerghoh 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by joerghoh

Hi,

I wouldn't do that this way, because it can open a security hole. Just call the models.json and let the server-side implementation all the rest. If the user has enough permissions, the "secured" data is included in the model, otherwise it's omitted (or a flag set to false). 

And yes, CUG is working with requests to model.json as well.

2 replies

joerghoh
Adobe Employee
joerghohAdobe EmployeeAccepted solution
Adobe Employee
February 22, 2020

Hi,

I wouldn't do that this way, because it can open a security hole. Just call the models.json and let the server-side implementation all the rest. If the user has enough permissions, the "secured" data is included in the model, otherwise it's omitted (or a flag set to false). 

And yes, CUG is working with requests to model.json as well.

Level 2
February 24, 2020

1. How caching works with SSR ? Looks like, with SSR enabled, the model json should not be cached and same goes with page. Because,  all pages have CUG based components.
2. Is CUG at component level is  OOTB with SSR ? I know page level CUG works OOTB with page model json and therefore in that case also, we can not even cache model json.

 

Singaiah_Chintalapudi
Level 7
March 29, 2021

Just a thought: Perform a thorough testing with the SDI. I would prefer writing a schedulers or other approaches instead of using SDI.