Sling Annotation | Community
Skip to main content
girishk14
Level 2
May 31, 2018 12:12 PM UTC
Solved

Sling Annotation

Hi All,

I have an use case to read the jcr property of component A from the page and use that value in my service implementation and display the processed value on page when that component A is used on a page.

Can I use the  @Model(adaptables = { Resource.class}) to get the resource for reading the jcr property in my service implementation (i.e can we use both @Model and @Component in my service implementation)

Is there any other way to implement the above described use cases.

Thanks in advance

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
smacdonald2008
smacdonald2008Accepted solution
Level 10
May 31, 2018 3:12 PM UTC

Look at that article i posted - Navin contributed that code!

8 replies

girishk14
girishk14Author
Level 2
May 31, 2018 3:43 PM UTC

Thanks all

Translate
smacdonald2008
smacdonald2008Accepted solution
Level 10
May 31, 2018 3:12 PM UTC

Look at that article i posted - Navin contributed that code!

Translate
girishk14
girishk14Author
Level 2
May 31, 2018 3:07 PM UTC

Could you please provide me the code snippet.

Translate
navinkaushal
Level 4
May 31, 2018 3:01 PM UTC

You can inject services directly inside the Model

Translate
navinkaushal
Level 4
May 31, 2018 3:00 PM UTC

You

Translate
smacdonald2008
Level 10
May 31, 2018 2:20 PM UTC
smacdonald2008
Level 10
May 31, 2018 2:19 PM UTC

YOu cannot mix @Model and @Component.

Translate
arunpatidar
New Participant
May 31, 2018 12:55 PM UTC