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

SOLVED

adaptTo() in sightly

khalidMomin
Level 4
Level 4

Hi All,

is there a way to adapt a resource to custom model class in sightly?

I have a custom model and i want to adapt a resource to it in sightly html code not in java.

Thanks,

Khalid

1 Accepted Solution
Feike_Visser1
Correct answer by
Employee
Employee

Sure this is possible. By default classes used in data-sly-use will be adapted from request or resource.

View solution in original post

0 Replies
Feike_Visser1
Correct answer by
Employee
Employee

Sure this is possible. By default classes used in data-sly-use will be adapted from request or resource.

khalidMomin
Level 4
Level 4

Thanks Feike,

Any code snippet or sample?

Feike_Visser1
Employee
Employee

<div data-sly-use.x="a.b.c">

${x.yourProperty}

</div>

khalidMomin
Level 4
Level 4

A function is returning me an object which is of type "Resource", i want to cast it to my model class.

like we do in java : Model model=resource.adaptTo(Model.class);

Something similar to this.

khalidMomin
Level 4
Level 4

Hi Feike,

I am a bit confused with this.

Can you provide me a snippet only instead of JIRA issue?

Feike_Visser1
Employee
Employee

I gave you the snippet already, right?

The JIRA is not yet released.