Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add multivalue property to jcr node through java code?

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.

like image 965
gstackoverflow Avatar asked Jul 19 '26 09:07

gstackoverflow


1 Answers

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"});
like image 142
Tomek Rękawek Avatar answered Jul 23 '26 23:07

Tomek Rękawek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!