HTL request attributes
While using <data-sly-include/> and <data-sly-resource/> it is now easy to pass 'requestAttributes'. These 'requestAttributes' can be accessed or processed in receiving HTL-script.
For eg.
<sly data-sly-use.settings="com.adobe.examples.htl.core.hashmap.Settings" data-sly-include="${ 'productdetails.html' @ requestAttributes=settings.settings}" />
And 'requestAttributes' can be passed from Java class.
public class Settings extends WCMUsePojo {
// used to pass is requestAttributes to data-sly-resource
public Map<String, Object> settings = new HashMap<String, Object>();
@Override
public void activate() throws Exception {
settings.put("order", "ascending");
}
}
Using requestAttributes using Sling-Model way.
@Model(adaptables=SlingHttpServletRequest.class)
public class ProductSettings {
@Inject @Optional @Default(values="empty")
public String order;
}
here 'order' is injected via the Map from the Use-class:
Go to HTL Tutorial Home page
No comments:
Post a Comment