Hi all,
I have a strange problem. I wrote a simple WebScript which should retrieve documents and its properties for defined category. Here is my code:
var categoryNode = search.luceneSearch("PATH:\"" + args.path + "\"");
if (categoryNode == undefined)
{
status.code = 404;
status.message = "Kategoria o referencji: " + args['path'] + " nie zostala znaleziona.";
status.redirect = true;
}
else
{
// perform category search
model.categoryFiles = search.luceneSearch("PATH:\"" + args.path + "//member\"");
}
This code works quite good. As an args.path I use qnamePath of the Category Node which I retrieve in other WebScript. The code is based on one of the WebScripts in the wiki page WebScripts Examples.
Response Template:
{
"feed": {
<#assign x = 0>
<#list categoryFiles as child>
<#if child.isContainer == false>
<#assign x = x+1>
"entry${x}": {
"param_title": "${child.name}",
<#list child.properties?keys as t>
<#– If the property exists –>
<#if child.properties[t]?exists>
<#– If it is a date, format it accordingly–>
<#if child.properties[t]?is_date>
"param_${t}" : "${child.properties[t]?date}",
<#– If it is a boolean, format it accordingly–>
<#elseif child.properties[t]?is_boolean>
"param_${t}" : "${child.properties[t]?string("yes", "no")}",
<#– Otherwise treat it as a string –>
<#else>
"param_${t}" : "${child.properties[t]}",
</#if>
</#if>
</#list>
<#assign y = 0>
<#list child.aspects as asp>
"aspect${y}" : "${asp}",
<#assign y = y+1>
</#list>
"param_href": "${absurl(url.serviceContext)}/api/node/content/${child.nodeRef.storeRef.protocol}/${child.nodeRef.storeRef.identifier}/${child.nodeRef.id}/${child.name?url}",
"param_icon" : "${url.context}${child.icon32}",
"param_nodeRef" : "${child.nodeRef}",
"param_nodeType" : "${child.type}",
"param_size" : "${child.size}"
},
</#if>
</#list>
"updated": "${xmldate(date)}"
}
}
And here id the problem. When I try to create JSON response I receive an error. It is connected with above Response Template. Everything works fine when I delete lines:
<#– Otherwise treat it as a string –>
<#else>
"param_${t}" : "${child.properties[t]}",
but then there are no String properties in the response. I would like to mention that I use the same RESPONSE TEMPLATE for my other WebScripts and everything is fine.
Can anyone help me with this issue?
Thanks in Advance,
Kamil Warcaba