<sly data-sly-resource="${item.imagePath @ resourceType='zkb/components/content/image', wcmmode='disabled', requestAttributes=model.breakpoints}"
data-sly-unwrap></sly>
Hi,
Can someone explain how to intreprete the requestAttribute in the template above?
model. breakpoints are evaluated from the model:
private static final Map<String, String> BREAKPOINTS_SIZES = Map.of("small", "300x200", "middle", "400x500", "normal", "600x750", "large", "600x750");
and are a map.
Solved! Go to Solution.
data-sly-resource="${item.imagePath @ resourceType='xxx/components/content/image', wcmmode='disabled', requestAttributes=model.breakpoints}"
@anasustic Aslo ref. https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/requestattributes-data-sly...
<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");
}
}
@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
Thank you @Manu_Mathew_
From what I can see, you are calling an AEM Component, and passing the requestAttributes parameter to your Sling Model backend.
If you are using Sling Model, from the backend, to capture the requestAttribute will be:
@RequestAttribute private String href;
If you are using WCMUsePojo, from the backend, to capture the requestAttribute will be:
get("href", String.class);
You can see how to pass data from Sightly to Sling Model
You can see how to pass data from Sightly to WCMUsePojo
@RequestAttribute private String href;
Thank you @BrianKasingli
I believe I use in the first approach in my implementation (passing from Sightly to Sling Model).
If I understand your very helpfull examples correctly, then @RequestAttribute in the Model comes from the Slightly HTL Component data-sly-use.linkResolve="${'com.sourcedcode.core.utils.use.LinkResolve' @ href='https://sourcedcode.com'}"?
What I do not understand in my example are the data parameters that are passed with a comma. I understand the item.imagePath is a resource that is passed to the image component under resrouceType and then additionally I have to data parameters that are passed to the model?
data-sly-resource="${item.imagePath @ resourceType='xxx/components/content/image', wcmmode='disabled', requestAttributes=model.breakpoints}"
is this code working? I tried it, does not work.
Hi Brian
I am sorry, but I am not sure which code you refer to?
data-sly-resource="${item.imagePath @ resourceType='xxx/components/content/image', wcmmode='disabled', requestAttributes=model.breakpoints}"
Yes, it is working.
Views
Likes
Replies
Views
Likes
Replies