how to get array values of a node property in jcr

25,354

Solution 1

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();     
}

Solution 2

Property nProp = node.getProperty("references");
Value[] values = propertyNode.getValues();
for (Value v : values) {
    System.out.println("Property Name = "+nProp.getName()+" ; Property Value= "+v.getString());
}
Share:
25,354
Admin
Author by

Admin

Updated on June 23, 2020

Comments

  • Admin
    Admin about 4 years

    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