cancel
Showing results for 
Search instead for 
Did you mean: 

args from get.js to .get.html.ftl

redraccoon
Star Contributor
Star Contributor

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

1 ACCEPTED ANSWER

redraccoon
Star Contributor
Star Contributor

in the get.js

model.custom = "rien";

in the ftl

"${custom}"

View answer in original post

3 REPLIES 3

mehe
Elite Collaborator
Elite Collaborator

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...

redraccoon
Star Contributor
Star Contributor

in the get.js

model.custom = "rien";

in the ftl

"${custom}"

mehe
Elite Collaborator
Elite Collaborator

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.

Getting started

Explore our Alfresco products with the links below. Use labels to filter content by product module.