Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

How to add a property to a node?

Avatar

Former Community Member

CQ.HTTP.post("/content/corp/en_us/test/jcr:content", null, {

   "jcr:primaryType" : "cq:PageContent",

   "propertykey" : "propertyvalue"

});

How can I give property type to it ?

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

If you want to provide type information, you can check the documentation at [1].

CQ.HTTP.post("/content/corp/en_us/test/jcr:content", null, { "jcr:primaryType" : "cq:PageContent", "propertykey" : "propertyvalue", "isboolean@Boolean" : "true" });

 

[1] https://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-po...

View solution in original post

3 Replies

Avatar

Correct answer by
Employee Advisor

If you want to provide type information, you can check the documentation at [1].

CQ.HTTP.post("/content/corp/en_us/test/jcr:content", null, { "jcr:primaryType" : "cq:PageContent", "propertykey" : "propertyvalue", "isboolean@Boolean" : "true" });

 

[1] https://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-po...

Avatar

Former Community Member
Hi Jörg Hoh , CQ.HTTP.post("/content/corp/en_us/test/jcr:content", null, {
   "jcr:primaryType" : "cq:PageContent",
   "propertykey" : "propertyvalue",
   "isboolean@Boolean" : "true"
});
"isboolean@Boolean" : "true" This got updated as new property, Instead of the type of "propertykey"

So please suggest how can we give the type to a property ?

Avatar

Level 10

What is your use case - looks like you are trying to post values to an AEM Servlet. That is a valid use case. However, in the Sling Servlet - use the JCR API to add props to a node. See this article on how to use the JCR API from within an OSGi bundle.

In this use case - we are adding props to a Customer node. 

https://helpx.adobe.com/experience-manager/using/persisting-cq-data-java-content1.html

You have much more control over writing a Sling Servlet if your use case is to use a Servlet to update the JCR.