Diese Konversation wurde aufgrund von Inaktivität geschlossen. Bitte erstellen Sie einen neuen Post.
Level 1
Level 2
Melden Sie sich an, um alle Badges zu sehen
Diese Konversation wurde aufgrund von Inaktivität geschlossen. Bitte erstellen Sie einen neuen Post.
How to read the null property array value?
Example:
Property type Value
area String[]
My requirement is i want to read the property which has a value as NULL
Please help me out to fix the issue.
Thanks!
MIke
Gelöst! Gehe zu Lösung.
Zugriffe
Antworten
Likes gesamt
Here is more information on this subject. Lets assume that we have this property that is a String array:
[img]StringArr.png[/img]
As you can see -- testprop is empty and a String[]. To read this value - you use the JCR API and the following code:
// Retrieve content
Node node = root.getNode("adobe/cq");
Property references = node.getProperty("testprop");
Value[] values = references.getValues();
String myVal = values[0].getString();
Here is a screenshot of debugging the code -- look at the value.
[img]StringArr2.png[/img]
Zugriffe
Antworten
Likes gesamt
To read a property of a node (the prop can be String, String[], etc) - you can use the JCR API. If the prop is a String[], it will return the value. If the array is empty, this empty value is returned. To learn how to work with the JCR API, see:
http://helpx.adobe.com/experience-manager/using/programmatically-accessing-cq-content-using.html
Zugriffe
Antworten
Likes gesamt
Here is more information on this subject. Lets assume that we have this property that is a String array:
[img]StringArr.png[/img]
As you can see -- testprop is empty and a String[]. To read this value - you use the JCR API and the following code:
// Retrieve content
Node node = root.getNode("adobe/cq");
Property references = node.getProperty("testprop");
Value[] values = references.getValues();
String myVal = values[0].getString();
Here is a screenshot of debugging the code -- look at the value.
[img]StringArr2.png[/img]
Zugriffe
Antworten
Likes gesamt
smacdonald2008 wrote...
Here is more information on this subject. Lets assume that we have this property that is a String array:
As you can see -- testprop is empty and a String[]. To read this value - you use the JCR API and the following code:
// Retrieve content
Node node = root.getNode("adobe/cq");
Property references = node.getProperty("testprop");
Value[] values = references.getValues();
String myVal = values[0].getString();
Here is a screenshot of debugging the code -- look at the value.
Hi,
Thanks for your reply.
I have tried with the below code
Node n=adminSession.getNode("/content/xxx/tra/jcr:content/parsys/columns/1/blockcontent_1");
Property prop=n.getProperty("area");
Value[] val=prop.getValues();
String str=val[0].getString();
The above code is works once the property has a value.
else
its thows an Exception ArrayIndexOutOfBoundsException: 0
Could you please help me to go ahead
Thanks
mike
Zugriffe
Antworten
Likes gesamt
You should check the length of the val array before reading properties from it. In this case, it would seem to be an empty array, so reading the 0 index produces that ArrayIndexOutOfBoundsException.
Zugriffe
Antworten
Likes gesamt
Zugriffe
Likes
Antworten
Zugriffe
Likes
Antworten