Hi,
I am trying to set values to one string[] multi valued property in the CQ page. i am doing it through remote java application not in CQ environment.
Here is the code that i am using
Value[] values = new Value[10];
values[0] = session.getValueFactory().createValue("NewValue-one");
values[1] = session.getValueFactory().createValue("NewValue-two");
while(nodeIter.hasNext())
{
Node myNode= nodeIter.nextNode();
myNode.getName();
myNode.setProperty("cq:tags", values);
}
I am not getting any exceptions while setting the property but after setting the values to the property, i looked into the properties tab in the CRXDE and i am seeing the values are not set and it's empty.
Here is the screenshot of properties tab in the CRXDE
Can someone help me on this? Let me know if you need anymore info.
Solved! Go to Solution.
Views
Replies
Total Likes
In myNode.setProperty("cq:tags", values); values has to be String[] and save session.
myNode.getSession().save();
Ref: https://docs.adobe.com/docs/en/spec/jsr170/javadocs/jcr-2.0/javax/jcr/Node.html#setProperty(java.lan..., java.lang.String[])
In myNode.setProperty("cq:tags", values); values has to be String[] and save session.
myNode.getSession().save();
Ref: https://docs.adobe.com/docs/en/spec/jsr170/javadocs/jcr-2.0/javax/jcr/Node.html#setProperty(java.lan..., java.lang.String[])
That is correct - you need to use an array.
Views
Replies
Total Likes
I agree with you. But In my case i am setting value to the "cq:tags" property. whenever i am setting the values using the above code, the value becomes empty in the cq:tags property.
Do we need to do in a different way to set multivalue to the property cq:tags?
Views
Replies
Total Likes
Edit :- Correcting my answer
Arun,
Could you please check if the tags you are trying to set is already present under /etc/tags ? If not your values will never set to cq:tags property
Thanks
Veena
Hi Scott.
We cannot set tags as normal properties. Those needs to be handled using TagManager API
Views
Replies
Total Likes
Views
Replies
Total Likes
I will check that . Before doing that i am trying to access tag manager api but can't get access to getTagManager method.
I can't able to call get TagManager method using the JCRTAG manager resolver factory. It's throwing me error. Here is my code
JcrTagManagerFactory.getTagManager(session); //throwing compile time error
Views
Replies
Total Likes
We have a discussion on how to get a TagManager API object in a HTL Java component here -- Adobe Experience Manager Help | Developing HTML Template Language Components that search for Adobe E...
Views
Replies
Total Likes
Hi Arun
For tag related operations, you should use tag manager API TagManager ("The Adobe AEM Quickstart and Web Application.")
To get a TagManager object , you can do the following
Please refer sample codes to work with TagManagers here Java Code Example com.day.cq.tagging.TagManager
Java Code Example com.day.cq.tagging.TagManager
Thanks
Veena
Views
Replies
Total Likes
Hey Guys,
Thanks for your valuable information. It was very helpful. At-last i found solution to my problem. I am connecting CQ remotely through my java code and i am not using Sling or OSGI . Because my application is not running in any of the CQ servers and it's running remotely in apache tomcat server. So i am using only JCR api to connect to CQ server and modifying the contents. Here is the code which used for tagging.
Node jcrNode=session.getNode("/etc/tags/default");
Node my_casecustom=jcrNode.addNode("my_casecustom","cq:Tag");
jcrNode.addMixin("mix:referenceable");
session.refresh(true);
session.save();
my_casecustom.setProperty("jcr:title", "custom,my case");
my_casecustom.setProperty("jcr:title.en_us", "custom,my case");
my_casecustom.setProperty("sling:resourceType", "cq/tagging/components/tag");
session.refresh(true);
session.save();
After i added CQ:TAGS property into my pagecontent node and it's settings the values to corresponding node.
Views
Replies
Total Likes