How to get project app id or artifact id in sling model | Community
Skip to main content
Level 2
Aug 4, 2023 7:00 AM UTC
Solved

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

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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
arunpatidar
arunpatidarAccepted solution
New Participant
Aug 4, 2023 10:27 AM UTC

HI @nikitatailor24 

You can try to retrieve bundle version if that helps.

 

 

Arun Patidar

4 replies

arunpatidar
arunpatidarAccepted solution
New Participant
Aug 4, 2023 10:27 AM UTC

HI @nikitatailor24 

You can try to retrieve bundle version if that helps.

 

 

Translate
Arun Patidar
varun249715
Employee
Aug 4, 2023 8:16 AM UTC

@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.

Translate
SivakumarKanoori
New Participant
Aug 4, 2023 8:15 AM UTC

@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

Translate
Thanks,Siva
Nishant-Singh
Employee
Aug 4, 2023 7:57 AM UTC

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

Translate