- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2017 10:27 AM
Hello
I have a simple dashlet
I just woud like to send a custom variable from my file get.js to my freemarker
something like this
my files get.js
***********************
function main()
{
var remoteURL = "/dashlet/relance"; //the url of the webscript repo
var connector = remote.connect("alfresco");
var json = connector.get(remoteURL);
var result = eval("(" + json + ")");
model.allRelances = result.relance; //this is actually working
var structure = ' {"structure" : [ { "struct" : "CUSTOM_VAR" } ] } ';
model.structure = structure;
}
main();
*********************
and in my file .get.html.ftl I could use it in condition
<#if structure.struct??>
<#if structure.struct == "custom_condition">
thank you
- Labels:
-
Alfresco Content Services
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2017 11:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2017 11:11 AM
For converting between Json string representation and JavaScript objects and vice versa, you can use Alfresco's jsonUtils (see docs.alfresco.com).
But to get the value of your custom variable you could just write
model.structure={struct:"CUSTOM_VAR"}
then you get "CUSTOM_VAR" from using structure.struct in your template. I think...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2017 11:13 AM
in the get.js
model.custom = "rien";
in the ftl
"${custom}"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2017 11:23 AM
In ftl you need to use ${variablename} to eval your variable to a string - used mainly for "printout" it's value.
In Conditions, loops, etc. you can use your variables directly.
