Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list
SOLVED

determining node typr

Avatar

Level 3

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

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