Search code examples
magnolia

Multivalued property


I would like to get a value for the multivalued property validation.

The code I used is as follows:

        println ("*** Listed are properties for the " +  childArea.getName() + " child: ***");
        while(propOfChildArea.hasNext())
        {
            Property pchildofarea = propOfChildArea.nextProperty();
             if (!pchildofarea.isMultiple()) {

                        String namechofarea = pchildofarea.getName();
                        String valchofarea = pchildofarea.getString();
                        println(String.format("|%-50s", "property_name:"+ namechofarea) + String.format("|%-50s"," property_value: " + valchofarea));

                    } else{
                        println("################here is a multiple property: "+ pchildofarea.getName());
                        Value[] value = pchildofarea.getValues();
                        println("value is:" + value[value.size()-1]);
                    }


        }

I would expect to get a value for this poperty but instead I get org.apache.jackrabbit.spi.commons.value.QValueValue@5c24b9c

enter image description here


Solution

  • When one does getValues() it actually fetches a Value object @see ->

    javax.jcr.Value
    

    On top of that, you should get the concrete value of the property and that depends on the expected property type. In general, you can fetch the value via javax.jcr.Value#getString

    Cheers,

    Hope that helps,