Expand my Community achievements bar.

SOLVED

How to get project app id or artifact id in sling model

Avatar

Level 2

I'm using AEM Cloud and I want to retrieve some data for a page using sling model. For that appID or artifactId is required in sling model. Is there a way to get this is sling model?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

HI @NikitaTailor24 

You can try to retrieve bundle version if that helps.

 

arunpatidar_0-1691144862469.png

 



Arun Patidar

View solution in original post

4 Replies

Avatar

Employee

Not sure why you need appID or artifactId ? can you please provide your use case ?

Avatar

Community Advisor

@NikitaTailor24  : 

 

If your use case is to just to read data from AEM JCR nodes and display on the page You don't need to have app id or artifact id. 

You can use sling model :

You can simply read the data from JCR and map to the sling model variables . Using sightly you can simply display the data.

 

Sling Models:

Sling Models are annotation driven Java “POJO's” (Plain Old Java Objects) that facilitate the mapping of data from the JCR to Java variables.

 

Thanks 

Siva

Thanks,
Siva

Avatar

Employee

@NikitaTailor24 I dont think there is an option for this directly in Sling Model.

What is your use case? 

 

However if you require just the app id or artifact id you can store it in an OSGI config and retrieve it in your sling model.

Avatar

Correct answer by
Community Advisor

HI @NikitaTailor24 

You can try to retrieve bundle version if that helps.

 

arunpatidar_0-1691144862469.png

 



Arun Patidar