Développer ma barre des réalisations de la Communauté.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

Cette conversation a été verrouillée en raison de son inactivité. Veuillez créer une nouvelle publication.

RÉSOLU

Meaning of the requestAttribute?

Avatar

Level 8
<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. 

1 solution acceptée

Avatar

Réponse correcte par
Community Advisor and Adobe Champion
data-sly-resource="${item.imagePath @ resourceType='xxx/components/content/image', wcmmode='disabled', requestAttributes=model.breakpoints}"

Voir la solution dans l'envoi d'origine

8 Replies

Avatar

Community Advisor

@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

 

Avatar

Level 8

Thank you @Manu_Mathew_ 

Avatar

Community Advisor and Adobe Champion

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

How to Pass Data Parameters to Sling Modal from Sightly HTL Component

 

You can see how to pass data from Sightly to WCMUsePojo

How to Pass Data Parameters to WCMUsePojo from Sightly HTL Component

@RequestAttribute private String href;

Avatar

Level 8

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}"

 

Avatar

Community Advisor and Adobe Champion

is this code working? I tried it, does not work. 

Avatar

Level 8

Hi Brian

I am sorry, but I am not sure which code you refer to?

Avatar

Réponse correcte par
Community Advisor and Adobe Champion
data-sly-resource="${item.imagePath @ resourceType='xxx/components/content/image', wcmmode='disabled', requestAttributes=model.breakpoints}"

Avatar

Level 8

Yes, it is working.