Passing Sling Model property from parent to child parsys component | Community
Skip to main content
Level 2
August 24, 2022
Solved

Passing Sling Model property from parent to child parsys component

  • August 24, 2022
  • 1 reply
  • 998 views

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.

 

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

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).

1 reply

joerghoh
Adobe Employee
joerghohAdobe EmployeeAccepted solution
Adobe Employee
August 24, 2022

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).

Giuderos1Author
Level 2
August 24, 2022

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?
joerghoh
Adobe Employee
Adobe Employee
August 24, 2022

I used this approach succesfully.