Skip to content

1.0.15 release

Compare
Choose a tag to compare
@jcheron jcheron released this 14 Oct 23:46
· 28 commits to master since this release
2e56c06

Added

  • JavascriptMultiModulesResource class -> For the creation of several scripts (modules) in the same JS file, with the possibility of incorporating java variables.

Usage:

Javascript multi modules resource

To avoid the multiplicity of javascript files, it is possible to group several scripts in the same file.

Each script (qualified as a module) must be identified in the javascript file by a comment on a single line bearing its name, and a comment marking the end (also mentioning the name of the script).

resource/static/js/multi.js

Each script can possibly be isolated, which is without consequences.

//resource/static/js/multi.js
//----------------consoleMsg-----------------------
console.log("${message}");
//----------------consoleMsg (end)-----------------

//----------------alertMsg-------------------------
(function(){
    alert("${message}");
})();
//----------------alertMsg (end)-------------------
In the java controller
	@GetMapping("sampleMulti")
	public String testJsMulti(@ModelAttribute("vue") VueJS vue) throws IOException {
		JavascriptMultiModulesResource jsMulti=JavascriptMultiModulesResource.create("multi");
		jsMulti.getModule("consoleMsg").put("message", "This is a console message");
		vue.addMethod("click", js.parseContent("consoleMsg"));
		return "view";
	}