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
Solved! Go to Solution.
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...
in the get.js
model.custom = "rien";
in the ftl
"${custom}"
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.
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.