ValueMap vs Node property | Community
Skip to main content
New Participant
April 2, 2018
Solved

ValueMap vs Node property

  • April 2, 2018
  • 4 replies
  • 3962 views

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.
Best answer by Julio_Tobar

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

New Participant
April 10, 2018

Thanks Julio Tobar, it's really helpful

smacdonald2008
New Participant
April 3, 2018

Nice response!

Julio_Tobar
Julio_TobarAccepted solution
New Participant
April 2, 2018

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,

joerghoh
Employee
April 2, 2018

"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