Menu

How to check the node property type is single value or multi value in aem?

We can check the type of property(whether single or multiple) using the method isMultiple() of Property interface. Below is an example to check the node property "items" is a single value or multiple values and based on that get the value or values for that property in AEM.

 

Property property = node.getProperty("items");
Value[] values = null;
if(property.isMultiple()){
   values = property.getValues();
} else { 
   values[0] = property.getValue();

} 


Hope this helps. Thank you! 

No comments:

Post a Comment