javalinked-listjcrmagnoliaxpathnodeiterator

Magnolia JCR get LinkedList Property Items


enter image description here

I am trying to retrieve the node 0's property - tag values, which is a linkedList object property I believe. as you can see it is [****,****]

I wish to retrieve the object value and store into a List<String> object So I can get the each value out for late use, e.g

String idA = "542f74fd-bfaf-4377-854a-8e62082edc6c"; 
string idB = "39aab11f-243f-464c-ae6d-c1f069f17d6c";

My attampt is something like below:

List<String> tagList = new ArrayList<String>();
tagList = componentNode.getProperties(node, "tags");

also tried this:

List<String> tagList = new ArrayList<String>();
tagList = PropertyUtil.getProperty(node, "tags");

but none of them works.

Please suggest me with code sample. Thanks


Solution

  • I believe they are called multi value properties in JCR and is supported via Arrays instead of Lists.

    I haven't tested the code myself but I believe it'll work. This should do the trick:

      Property property = node.getProperty("tags");     
      Value[] tags = property.getValues();
    

    and then you can convert/wrap it to List if you really want to.

    Hope that helps,

    Cheers,