This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

AnnouncementAnnouncement Module

Collapse

No announcement yet.

How to use spring:url tags variable in a seprate Javascript file..?Page Title Module

You are using tiles, so every tile that is using a tag library must declare it. So if your javascript is embedded in a JSPX file as another tile from the main one, you'll need to mount the spring: library in the top level tag of that page.

Also, if you're just importing a file that is a Javascript file and expecting Roo to interpolate the variable for you, the JSP compiler is not going to compile it - it is downloaded at the browser level. You can have a scriptlet execute within the JSPX file after importing the script file, and the scriptlet (that perhaps calls a function in the javascript file) can refer to the ${some_url_var} parameter.

You just can't do that. JSP files are interpreted on the server, the results are outputted and sent back to the client. JavaScript is executed on the client. It is already too late to send a live variable.

Just declare a JavaScript function in your script, and in your JSPX file do something like:

<script>

do_something("${my_jsp_var}");

</script>

Then, the jspx file will interpret the value of the variable and send it to the script in the js file. Write the function to do the setup of your JavaScript work.