Hi Team,
Hope you are doing great.
Can anyone please help me how we save meta keyword pragmatically.
I have tried with this code but this is not works
Resource tagResource = resourceResolver.getResource("/content/ranosys-website/in/home/about-us/career/jcr:content");
Node myNode = tagResource.adaptTo(Node.class);
myNode.setProperty("cq:tags", "custom message bhagchand ");
Session session = resourceResolver.adaptTo(Session.class);
session.save();
Thanks in advance
Bhagchand
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @bhagchand
Please create a session object first and try to add the property later.
Example here: https://helpx.adobe.com/ca/legal/product-descriptions/aem-cloud-service.html
Hope this helps!
Thanks,
Kiran Vedantam.
Hi @bhagchand,
To summarize your question, do you want to add a property to your resource programatically?
In your doPost method, make these changes.
Resource tagResource = resourceResolver.getResource("/content/ranosys-website/in/home/about-us/career/jcr:content");
Node myNode = tagResource.adaptTo(Node.class);
myNode.setProperty("meta", "your description");
resourceResolver.commit();
this will add a property to the mentioned node.
Thanks, but this is alos not work
please share any other solution
Hi @bhagchand,
If that's not working, I believe there are other things to discuss.
1. are you using a servlet/service to do the operation? if yes, what is your error log saying?
2. the operation may not get success if there are any issues with your ajax-call/trigger event.
3. if you are going with the session way, please create a Session object first and try to add the property later as @Kiran_Vedantam said.
with the resourceResolver way, here is an example
Thank you.
Hi @bhagchand
Please create a session object first and try to add the property later.
Example here: https://helpx.adobe.com/ca/legal/product-descriptions/aem-cloud-service.html
Hope this helps!
Thanks,
Kiran Vedantam.
Hi @bhagchand ,
Instead of using the jcr node API you should use the ModifiableValueMap. This is recommended. Try below snippet
Resource tagResource = resourceResolver.getResource("/content/ranosys-website/in/home/about-us/career/jcr:content"); ModifiableValueMap map = tagResource.adaptTo(ModifiableValueMap.class); map.put("cq:tags", "custom message bhagchand"); resource.getResourceResolver().commit();
Views
Likes
Replies
Views
Likes
Replies