Class JavascriptResource
java.lang.Object
io.github.jeemv.springboot.vuejs.utilities.resources.JavascriptResource
JavascriptResource This class is part of springBoot-VueJS Allows to
Externalize a js script (from resources/static/js) and to use java variables
in it.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds all members name/value of an object to java contents.voidaddVariables(Object[][] keyValues) Adds an array of names,values to the resource.voidaddVariables(String jsonString) Adds names,values of contents to the resource from a json array.static JavascriptResourceCreates and returns a javascript resource.static JavascriptResourceCreates and returns a javascript resource.static StringReturns the javascript content of a javascript file parsed with java contents.voidLoads a javascript file.Returns the javascript content of the file parsed with the java contents.Adds java content identified by its name.
-
Constructor Details
-
JavascriptResource
public JavascriptResource() -
JavascriptResource
-
-
Method Details
-
put
Adds java content identified by its name.- Parameters:
name- The name of the java content (use ${name} in the js file to refer to it.value- The java content- Returns:
- the previous value associated with name, or null if there was no mapping for name.
-
addVariables
Adds an array of names,values to the resource.- Parameters:
keyValues- Sample new Object[][] { {"id",5},{"name","doe"} }
-
addVariables
Adds names,values of contents to the resource from a json array.- Parameters:
jsonString- sample "{'id':5}"- Throws:
IOException
-
addVariables
Adds all members name/value of an object to java contents.- Parameters:
o-- Throws:
IOException
-
loadFile
Loads a javascript file.- Parameters:
filename- The name of the js file- Throws:
IOException
-
parseContent
Returns the javascript content of the file parsed with the java contents.- Returns:
- The javascript parsed with the java contents
-
load
Returns the javascript content of a javascript file parsed with java contents.- Parameters:
filename- The javascript file to loadvariables- The java contents to be parsed.- Returns:
- The javascript content of the file parsed with the java contents
- Throws:
IOException
-
create
public static JavascriptResource create(String filename, Map<String, Object> variables) throws IOExceptionCreates and returns a javascript resource.- Parameters:
filename- The javascript file to loadvariables- The javascript content of the file parsed with the java contents- Returns:
- A Javascript resource
- Throws:
IOException
-
create
Creates and returns a javascript resource.- Parameters:
filename-- Returns:
- The javascript file to load
- Throws:
IOException
-