Expand my Community achievements bar.

Posting content to the JCR via AJAX: Dynamic Node Creation

Avatar

Level 2

Hello,

When making an ajax call to create nodes in the jcr, the node's (nameHint) name is transformed to lowercase. Is there a key / value pair I can pass into my datastring object to prevent this from happening? Also, I am noticing that double-byte characters are not being added correctly.

技術能力 - 卓越したエンジニアリング | 日本ムーグ is being converted to 技術能力 - 卓越したエンジニアリング | 日本ムーグ

 

Here is the ajax call I am making to create the node. The nodes are being created and any custom property I add shows up in the correct case. The physical node name that you see along the left hand side in crx is transformed to lower case: mainCol becomes maincol

$.ajax({ url: "http://<host>:<port>/bin/querybuilder.json?path=<my path>&type=cq:Page&path.self=true&orderby=path&orderby.sort=asc&p.hits=selective&p.properties=jcr:path%20jcr:content/cq:template&p.limit=1", success: function(data) { var hits = data.hits, len = hits.length; for (var i = 0; i < len; i++) { console.log(hits[i]['jcr:path']); var datastring = { "sling:resourceType": "wcm/foundation/components/parsys", ":nameHint": "mainCol", // This is being transformed "jcr:primaryType": "nt:unstructured" }; $.ajax({ type: 'post', async: false, data: datastring, url: 'http://<host>:<port>' + hits[i]['jcr:path'] + '/jcr:content/', success: function(data) { console.log('Success'); } }); } } });

Here is the second call I'm making. This one allows me to add properties to pages / nodes that I create. As I mentioned above, double-byte characters are being transformed when creating these custom properties. Is there another key/value pair I can add to my properties object that will prevent this from happening?

var properties = { navTitle: hits[i]['H2-1'], 'jcr:description': hits[i]['Meta Description 1'] }; $.ajax({ type: 'post', async: false, data: properties, url: <path to the page or node>  + '/jcr:content', success: function(data) { console.log('Success'); } });
     
$.ajax({
url: "http://52.70.22.162:4502/bin/querybuilder.json?path=/content/sites/italy/it&type=cq:Page&path.self=t...",
success: function(data) {
var hits = data.hits,
len = hits.length;

for (var i = 0; i < len; i++) {
console.log(hits[i]['jcr:path']);

var datastring = {
"sling:resourceType": "wcm/foundation/components/parsys",
":nameHint": "mainCol",
"jcr:primaryType": "nt:unstructured"
};

$.ajax({
type: 'post',
async: false,
data: datastring,
url: 'http://52.70.22.162:4502' + hits[i]['jcr:path'] + '/jcr:content/',
success: function(data) {
console.log('Success');
}
});
}
}
});
0 Replies