Expand my Community achievements bar.

SOLVED

ValueMap vs Node property

Avatar

Level 2

HI Friends,

Can you pls explain the difference between the below

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

Thanks in advance

Akbar

1 Accepted Solution

Avatar

Correct answer by
Level 3

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,

View solution in original post

4 Replies

Avatar

Employee Advisor

"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

Avatar

Correct answer by
Level 3

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,

Avatar

Level 2

Thanks Julio Tobar, it's really helpful