Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

request getattribute in Sightly set from slingmodel


Community Advisor

I am trying to get attribute value set in Slingmodel class. Below code is used to set value of attribute "mycustomparam" in sling model. 


request.setAttribute("mycustomparam", "value");

But unable to get this value in HTL

I have tried 

${request.attribute @ mycustomparam}

 In other model2.java, i am able to get this value using request.getAttribute('mycustomparam');

Is there any way to get value in sightly instead of model?


5 Replies


Level 5

Seems there isn't a way to directly access the request attributes in sightly and requires JS Use API. Here's a super short sample code to do just that: https://gist.github.com/gabrielwalt/a6a022ee65b3839d08bb4deb59211e57



Community Advisor

@Nikhil_Verma yup there is no way to access request getattribute directly in sightly. We can use either js or separate model to get setted value.


Community Advisor

why don't you write a get method to export attribute value in Sling Model to get the value in HTL?





private mycustomparam;
request.setAttribute("mycustomparam", value);
mycustomparam = value;

public String getMycustomparam(){
return mycustomparam;


Arun Patidar


Community Advisor

@arunpatidar Use case is different. I need to set value in request parameterin model1.java andneed this value in different model model2, which si working fine in my implemenation.