Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

setProperty("Name", String[])

viren_pushpanay
Level 3
Level 3

Hi,

 

When I use the method setProperty("Name", String[]) only the Name and type are added to the JCR. The Value is empty. But if I use setProperty("Name", "Value") everything is fine. 

pageResource = page.adaptTo(Resource.class); Resource jcrContentResource = pageResource.getChild(JcrConstants.JCR_CONTENT); Node pageNode = jcrContentResource.adaptTo(Node.class); try { String[] tempIds = ids.toArray(new String[ids.size()]); pageNode.setProperty("cq:tags", tempIds); LOG.debug("Stuff of tags: "+tempIds[0]); LOG.debug("Tag size: "+tempIds.length); resourceResolver.commit(); } catch (Exception e) { LOG.error(e.getMessage(), e); }

Please see attached image.

What code be the problem?

 

Note: CQ version is 5.6.1

Thank you.

Cheers,

Viren.

1 Accepted Solution
Sam205505050
Correct answer by
Level 6
Level 6

have you tried like below - 

pageNode.setProperty("cq:tags", tempIds.class);

Ideally it should be: someNode.setProperty("value", String[].class);

View solution in original post

2 Replies
smacdonald2008
Level 10
Level 10

This method is supported in javax.jcr API.  

Interface Node

     
PropertysetProperty(java.lang.String name, java.lang.String[] values) 
          Sets the specified property to the specified array of values.

 

See:

http://www.day.com/maven/jsr170/javadocs/jcr-2.0/javax/jcr/Node.html?is-external=true

Sam205505050
Correct answer by
Level 6
Level 6

have you tried like below - 

pageNode.setProperty("cq:tags", tempIds.class);

Ideally it should be: someNode.setProperty("value", String[].class);

View solution in original post