Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get array values of a node property in jcr

Tags:

jcr

aem

Need help in getting the string[] values of node property??

for example I have a node image which has property "references" of type String[] . I need to get the first value of array.

Thanks

like image 460
user2000633 Avatar asked Dec 09 '22 18:12

user2000633


1 Answers

From the Node, you can get the references property. And then call getValues to the reference values. From there, just take the first. Something like

public String getFirstReference(Node node) throws RepositoryException {
  Property references = node.getProperty("references");     
  Value[] values = references.getValues();
  return values[0].getString();     
}
like image 182
diffa Avatar answered Jan 10 '23 06:01

diffa