Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

determining node typr

Avatar

Former Community Member

Hi,

I want to know if there is anyway using which I can programatically determine the node type. For example: while iterating through nodes, I would like to check if a node if of type image and if yes then I want to write some logic.

Thanks in advance,

Ankit

1 Accepted Solution

Avatar

Correct answer by
Level 7

Hi Ankit.
Use node.getPrimaryNodeType() to get the primary type for the node or use node.isNodeType("Nodetypename") to check if the node is of a certain type.

http://www.day.com/maven/jsr170/javadocs/jcr-1.0/javax/jcr/Node.html

Good Luck

/Johan

View solution in original post

2 Replies

Avatar

Level 2

For an image, jcr:primaryType is dam:Asset while for a page jcr:primaryType is cq:Page.

Avatar

Correct answer by
Level 7

Hi Ankit.
Use node.getPrimaryNodeType() to get the primary type for the node or use node.isNodeType("Nodetypename") to check if the node is of a certain type.

http://www.day.com/maven/jsr170/javadocs/jcr-1.0/javax/jcr/Node.html

Good Luck

/Johan