All executions on the
HstComponent instances, hierarchically oraganized in a page, share a single
HstRequestContext object, which can be accessed through either
And, the execution order on
HstCompnoent instances in the page is “parent to child” when invoking
#doBeforeRender() methods, and the reversed, “child to parent”, when rendering each component using hst templates (e.g, FTL). [1,2]
Therefore, you could try any of the following:
- You can simply set an attribute through
HstRequestContext.setAttribute(...) in a parent component’s
#doBeforeRender() and get the attribute in descendants.
- Or you can. add a utility class with a static method which uses
RequestContextProvider.get() to get the current thread’s
HstRequestContext to return the sharable attribute if existing, or create one if not set yet.