How to add a property to a node? | Community
Skip to main content
October 16, 2015
Solved

How to add a property to a node?

  • October 16, 2015
  • 3 replies
  • 1610 views

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 ?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by joerghoh

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-post.html#typehint

3 replies

joerghoh
joerghohAccepted solution
Employee
October 16, 2015

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-post.html#typehint

October 16, 2015
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
New Participant
October 16, 2015

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.