Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

Pass an object as a parameter to sling model/wcmusepojo from sightly(HTL)


Level 1


I'm converting a JSP into sightly for a component. In that component they are setting an object as a request attribute to be used in another component. We cannot set request attributes in sightly right? So I'm trying to send this object as a parameter to a sling model/wcmusepojo to set the request attribute there but I think we can only pass string values as arguments to slingmodels/wcmusepojo right? Is there any example of passing an object as a parameter to slingmodel/wcmusepojo? 


Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution


Correct answer by
Level 5
0 Replies


Community Advisor

You can not set request attribute from sightly but you can get it.

And also you can not pass a pure java object except String and some other like that so if you need any backend operation like setting request object you need to do it java only before it comes to the sightly.

if you still need to pass the parameter, you can do ti like that:


<sly data-sly-use.someObject="${'com.demo.core.models.DemoModel' @propertyOne='PropertyOne', propertyTwo='PropertyTwo'}>

Sling Model:

@Model(adaptables = { SlingHttpServletRequest.class })

public class DemoModel {



private String propertyOne;



private String propertyTwo;


//getter and setter





public class DemoUse extends WCMUsePojo {


    public void activate() throws Exception {

        String propertyOne = get("propertyOne", String.class);

        String propertyTwo = get("propertyTwo", String.class);



NOTE: update the name of the wcmusepojo accordingly.

this will help.


Umesh Thakur



Level 1
Thanks but can I pass a java object as well instead of string and do this -> get("propertyOne", JavaClassName.class); to get the object?


Level 1
Thanks but the problem is not getting the request object but passing an object as an argument to sling model/wcmusepojo


Correct answer by
Level 5

check out this similar query posted in the community that should help your problem.

The ultimate experience is back.

Join us in Vegas to build skills, learn from the world's top brands, and be inspired.

Register Now