Hi All
i am trying to get a property from a child node of the currentStyle HTL object.
have the below structure
/etc/designs/abc
basepage(page component)
|_
header (property)
i am trying to get a property saved in header node in base page component html
Able to read property from currentStyle, which gives basepage path.
I am trying to get a property from the header node under basepage.
there is a getsubstyle method in the Style class. but not able to get that to work
Style (The Adobe AEM Quickstart and Web Application.)
TIA
Solved! Go to Solution.
Views
Replies
Total Likes
You might not be able to do it with just HTL, since you cannot call methods which accepts some arguments in HTL. So, you will probably have to switch to a Sling model or a use js to get the intended style object.
You might not be able to do it with just HTL, since you cannot call methods which accepts some arguments in HTL. So, you will probably have to switch to a Sling model or a use js to get the intended style object.
Hi,
The method getsubstyle(String relativePath)
you are referring to requires an argument, relativePath
; otherwise, it won't work. As explained by @h_kataria, you cannot invoke methods with parameters via HTL. The recommended approach is to use a Sling Model, where you can do something like this:
@Model(adaptables = Resource.class)
public class MyModel {
@ScriptVariable
private Style currentStyle;
@PostConstruct
protected void init() {
// Get the substyle
Style subStyle = currentStyle.getSubStyle("/header");
// TODO: Get the properties from substyle or expose it directly to HTL
}
Hope this helps
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies