Hi everyone!
I would like to inject a page property into a Sling Model using annotations but I'm struggling. Like @ValueMapValue but for a page property.
Any ideas on how to do it?
Thanks!
Solved! Go to Solution.
Views
Replies
Total Likes
Page property is associated with the page and not to a component so I believe you cannot directly use inject or valuemapvalue to read the property.
However you can use the below annotations
@ScriptVariable
private ValueMap pageProperties;
@SlingObject
private Page currentPage;
which will read the properties and use the get method and retrieve the required property from the page.
Hope it helps
Views
Replies
Total Likes
Page property is associated with the page and not to a component so I believe you cannot directly use inject or valuemapvalue to read the property.
However you can use the below annotations
@ScriptVariable
private ValueMap pageProperties;
@SlingObject
private Page currentPage;
which will read the properties and use the get method and retrieve the required property from the page.
Hope it helps
Views
Replies
Total Likes
Hello @bruno-bradach
Sharing a cheat sheet for different annotations used in Sling Models (Including ValueMap).
https://sourcedcode.com/blog/aem/aem-sling-model-injectors-annotations-cheat-sheet-reference-guide
https://techrevel.blog/2017/03/18/sling-model-annotations/
It will help with current and later use-cases as well
Views
Replies
Total Likes
You can use thie hierarchical page property injector, easy! https://adobe-consulting-services.github.io/acs-aem-commons/features/sling-model-injectors/hierarchi... !
Views
Replies
Total Likes
Views
Likes
Replies