Expand my Community achievements bar.

SOLVED

adaptTo() in sightly

Avatar

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

Avatar

Correct answer by
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

7 Replies

Avatar

Correct answer by
Employee

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

Avatar

Level 4

Thanks Feike,

Any code snippet or sample?

Avatar

Employee

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

${x.yourProperty}

</div>

Avatar

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.

Avatar

Level 4

Hi Feike,

I am a bit confused with this.

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

Avatar

Employee

I gave you the snippet already, right?

The JIRA is not yet released.