public class JavaScript extends Object
Encapsulates JavaScript definitions.
Able to load JavaScript code from file or from classpath resource.
| Constructor and Description |
|---|
JavaScript(String javaScript)
Instantiates a new java script.
|
| Modifier and Type | Method and Description |
|---|---|
JavaScript |
append(String javaScriptPartToAppend)
Append the JavaScript part to end of the this JavaScript
|
static JavaScript |
fromFile(File sourceFile)
Loads the JavaScript from file.
|
static JavaScript |
fromResource(String resourceName)
Loads the JavaScript from classpath resource.
|
String |
getAsString()
Gets the JavaScript as string
|
String |
getIdentification()
Gets a identification for this script based on script's hashcode.
|
JavaScript |
join(JavaScript javaScriptToJoin)
Joins this JavaScript object with another JavaScript object to single JavaScript.
|
static JavaScript |
js(String javaScript)
The factory method for JavaScript object
|
JavaScript |
parametrize(Object... parameters)
Fills the parameters to placeholders in simplified format (look for Simplified format) to this JavaScript code
and returns the result.
|
String |
toString() |
public JavaScript(String javaScript)
javaScript - the java script codepublic static JavaScript js(String javaScript)
javaScript - codepublic String getAsString()
public JavaScript join(JavaScript javaScriptToJoin)
javaScriptToJoin - the JavaScript object we want to join withpublic JavaScript append(String javaScriptPartToAppend)
javaScriptPartToAppend - javaScript to append on the end of this JavaScriptpublic String getIdentification()
Gets a identification for this script based on script's hashcode.
It can be used to uniquely distinguish the script on the page.
public static JavaScript fromFile(File sourceFile)
sourceFile - the source fileRuntimeException - when failed to load a scriptpublic static JavaScript fromResource(String resourceName)
resourceName - the resource name, e.g. "org/jboss/test/..."RuntimeException - when failed to load a scriptpublic JavaScript parametrize(Object... parameters)
parameters - to parametrize this JavaScript codeCopyright © 2013 JBoss by Red Hat. All Rights Reserved.