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

How to add a property to a node?

parthapratim2
Level 2
Level 2

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
Jörg_Hoh
Correct answer by
Employee
Employee

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

0 Replies
Jörg_Hoh
Correct answer by
Employee
Employee

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

parthapratim2
Level 2
Level 2
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 ?

smacdonald2008
Level 10
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.