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

cancel
Showing results for 
Search instead for 
Did you mean: 
redraccoon
Established Member

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

Jump to solution

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 Solution

Accepted Solutions
redraccoon
Established Member

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

Jump to solution

in the get.js

model.custom = "rien";

in the ftl

"${custom}"

View solution in original post

3 Replies
mehe
Senior Member II

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

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

redraccoon
Established Member

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

Jump to solution

in the get.js

model.custom = "rien";

in the ftl

"${custom}"

mehe
Senior Member II

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

Jump to solution

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.