ValueMap vs Node property | Community
Skip to main content
Level 2
Apr 2, 2018 10:36 AM UTC
Solved

ValueMap vs Node property

HI Friends,

Can you pls explain the difference between the below

getProperties.get("propertyName").toString(); and node.getProperty("propertyName");

Thanks in advance

Akbar

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Julio_Tobar
Julio_TobarAccepted solution
Level 3
Apr 2, 2018 9:01 PM UTC

Dear @akbareee, you must first understand the technology stack that AEM relies on, which is:

  • OSGi
  • Java Content Repository (JCR)
  • Apache Sling
  • AEM Modules

You can access content stored in the repository by using APIs from any of the technologies; this would be the first big difference you asked for:

node.getProperty("propertyName");   --> Provided by JCR technology

getProperties.get("propertyName").toString();  ---> Provided by Apache Sling Technology

in case of "getProperties" your basically accessing a "globally available Sling object" whereas "node" must be an instance of Node class.

Regards,

4 replies

Level 2
Apr 10, 2018 12:27 PM UTC

Thanks Julio Tobar, it's really helpful

Translate
smacdonald2008
Level 10
Apr 3, 2018 12:18 AM UTC

Nice response!

Translate
Julio_Tobar
Julio_TobarAccepted solution
Level 3
Apr 2, 2018 9:01 PM UTC

Dear @akbareee, you must first understand the technology stack that AEM relies on, which is:

  • OSGi
  • Java Content Repository (JCR)
  • Apache Sling
  • AEM Modules

You can access content stored in the repository by using APIs from any of the technologies; this would be the first big difference you asked for:

node.getProperty("propertyName");   --> Provided by JCR technology

getProperties.get("propertyName").toString();  ---> Provided by Apache Sling Technology

in case of "getProperties" your basically accessing a "globally available Sling object" whereas "node" must be an instance of Node class.

Regards,

Translate
joerghoh
Employee
Apr 2, 2018 7:23 PM UTC

"getProperties" seems odd as variable name ... :-)

But the difference between these is the type of API; one is using the lowlevel JCR API, while the other one uses the Sling Resource API.

I wrote a blog post about some years ago, which I consider as still relevant: CQ5 coding patterns: Sling vs JCR (part 1) | Things on a content management system

Jörg

Translate