In my velocity template, I have a javascript variable like
var workflowInstanceNameText = document.getElementById('workflowInstanceName').value;
and I want to assign the javascript variable to velocity template variable.
#set(workflowName = 'someexpression here');
In the palce of some expression I have tried as below but its not assigning value
#set(workflowName = workflowInstanceNameText);
#set(workflowName = $workflowInstanceNameText);
Any help is appreciated.
Thanks in advance.
In my velocity template, I have a javascript variable like
var workflowInstanceNameText = document.getElementById('workflowInstanceName').value;
and I want to assign the javascript variable to velocity template variable.
#set(workflowName = 'someexpression here');
In the palce of some expression I have tried as below but its not assigning value
#set(workflowName = workflowInstanceNameText);
#set(workflowName = $workflowInstanceNameText);
Any help is appreciated.
Thanks in advance.
Share Improve this question edited Sep 24, 2012 at 15:37 Vikdor 24.1k10 gold badges65 silver badges85 bronze badges asked Sep 24, 2012 at 7:25 NPKRNPKR 5,5064 gold badges34 silver badges48 bronze badges2 Answers
Reset to default 5Velocity works on server side. JavaScript works on client side (browser). You can generate JavaScript using Velocity, but not the other way around.
Velocity templating happens on the server side. So, if you want your javascript variable that is on the client-side to be available during velocity template stage on the server side, you have to send that variable as a request parameter to your server-side servlet/action and refer to that request parameter in your velocity template.