Freemarker error in share webscript
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2013 04:00 PM
I have a very simple JS webscript on the Alfresco side (mytest.get.js)
I can use this on an Alfresco webscript freemarker template and it works fine on the Alfresco side. Example
Now I want to access this data from the Share side in a webscript .Example sharetest.get.js
function main() {
var data;
var connector = remote.connect("alfresco");
var result = connector.call("/mytest");
if (result.status == status.STATUS_OK)
{
data = eval('(' + result + ')');
}
model.desc1= data.someDesc;
}
main();
And use desc1 in a freemarker template on the Share side
I keep getting error : Error on line 4, column 26 in sharetest.get.html.ftl Expecting a string, date or number here, Expression desc1 is instead a freemarker.template.SimpleHash
What did I do wrong and how to correct it.
Thanks a bunch!
function main() { model.someDesc= "Some description text");}main();
I can use this on an Alfresco webscript freemarker template and it works fine on the Alfresco side. Example
<div class="dashlet"> <div class="title">Return Info WebScript</div> <div class="body"> <br>Value is ${someDesc}</br> </div></div>
Now I want to access this data from the Share side in a webscript .Example sharetest.get.js
function main() {
var data;
var connector = remote.connect("alfresco");
var result = connector.call("/mytest");
if (result.status == status.STATUS_OK)
{
data = eval('(' + result + ')');
}
model.desc1= data.someDesc;
}
main();
And use desc1 in a freemarker template on the Share side
<div class="dashlet"> <div class="title">Test getting value from Alfresco side</div> <div class="body"> <br>Description is ${desc1} </div></div>
I keep getting error : Error on line 4, column 26 in sharetest.get.html.ftl Expecting a string, date or number here, Expression desc1 is instead a freemarker.template.SimpleHash
What did I do wrong and how to correct it.
Thanks a bunch!
Labels:
- Labels:
-
Archive
4 REPLIES 4
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2013 04:26 PM
ViNg,
Your Alfresco webscript FTL should be formatting the response as a JSON object, not as HTML. When you call the Alfresco webscript from sharetest.get.js, you're running eval() on the result, and this method expects JSON. Your FTL for your Alfresco webscript could look something like this:
I hope this helps.
Your Alfresco webscript FTL should be formatting the response as a JSON object, not as HTML. When you call the Alfresco webscript from sharetest.get.js, you're running eval() on the result, and this method expects JSON. Your FTL for your Alfresco webscript could look something like this:
<#escape x as jsonUtils.encodeJSONString(x)>{ "description" : "${someDesc}"}</#escape>
I hope this helps.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2013 05:04 PM
Sorry I am a little new to FTL. Where do I put this code and what file?
Thanks a bunch!
Thanks a bunch!
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2013 06:06 PM
mytest.get.json.ftl
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2013 09:21 AM
Thank you much Parzgnat. It wworks well. Didn't know the view also plays important part. Thought only the controller is used for data. That was a great help!
