Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Passing Sling Model property from parent to child parsys component

Avatar

Level 2

Hi all,

as mentioned in the title is it possible to pass a sling model property to a child component dragged in a parsys?

 

I want to call an intensive method only once in the parent and then pass the result to all child components dragged in the page.

 

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Do you mean this structure?

 

 component 1 (which contains this intensive computation)
  |-> parsys
    |-> sub component 2 (which

 In this case it is hardly possible, because the parsys does not do that (at least that I am aware of).

 

When I was required to do so always in the context of a request, I used the RequestParameters and stored the result of the computation (and made sure that if the expected key was not present the computation was done again and stored in there).

View solution in original post

3 Replies

Avatar

Correct answer by
Employee Advisor

Do you mean this structure?

 

 component 1 (which contains this intensive computation)
  |-> parsys
    |-> sub component 2 (which

 In this case it is hardly possible, because the parsys does not do that (at least that I am aware of).

 

When I was required to do so always in the context of a request, I used the RequestParameters and stored the result of the computation (and made sure that if the expected key was not present the computation was done again and stored in there).

Avatar

Level 2

Exactly, the same structure.

 

Maybe I found a solution which consist in setting the result of the computation in an attribute of the SlingHttpServletRequest

 

request.setAttribute("result", ruleList);
 
Then getting the attribute in the Sling Model of the child component and assigning it to a variable
 
String ruleList = request.getAttribute("result");
Could be a possible solution?