determining node typr | Community
Skip to main content
October 16, 2015
Solved

determining node typr

  • October 16, 2015
  • 2 replies
  • 1025 views

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

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 Ojjis

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

Level 2
October 16, 2015

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

Ojjis
OjjisAccepted solution
Level 7
October 16, 2015

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