问题
According this answer
https://stackoverflow.com/a/18726682/2674303
I see that I can add property to node in crxde. But I don't understand how can I add multivalue property(array) to node.
Please, help.
回答1:
You have to create an array of values:
ValueFactory valueFactory = session.getValueFactory();
Node node = session.getNode("/content/path/to/my/node");
Value[] values = new Value[3];
values[0] = valueFactory.createValue("First value");
values[1] = valueFactory.createValue("Second value");
values[2] = valueFactory.createValue("Third value");
node.setProperty("propertyName", values);
alternatively, you may use a String array:
node.setProperty("propertyName", new String[] {"First value", "Second value", "Third value"});
来源:https://stackoverflow.com/questions/27121830/how-to-add-multivalue-property-to-jcr-node-through-java-code