Package org.primefaces.extensions.util
Class JavascriptVarBuilder
java.lang.Object
org.primefaces.extensions.util.JavascriptVarBuilder
Builds a JavaScript var object or array string. A simple way to generalized a lot of code used in renderers.
- Since:
- 6.2
- Author:
- Mark Lassiter / Melloware
-
Constructor Summary
ConstructorsConstructorDescriptionJavascriptVarBuilder
(String varName, boolean isObject) Constructs an instance of the builder. -
Method Summary
Modifier and TypeMethodDescriptionappendArrayValue
(String value, boolean quoted) Appends an array value.appendProperty
(String propertyName, String propertyValue, boolean quoted) Appends an Object name/value pair to the object.appendRowColProperty
(int row, int col, String propertyValue, boolean quoted) appends a property with the name "rYY_cXX" where YY is the row and XX is he column.appendText
(String value, boolean quoted) Appends text to the var stringcloseVar()
Closes the array or object.toString()
Returns the string for the var.
-
Constructor Details
-
JavascriptVarBuilder
Constructs an instance of the builder.- Parameters:
varName
- the variable nameisObject
- true if build an Object, false if an array.
-
-
Method Details
-
appendProperty
public JavascriptVarBuilder appendProperty(String propertyName, String propertyValue, boolean quoted) Appends an Object name/value pair to the object.- Parameters:
propertyName
- the property namepropertyValue
- the property valuequoted
- if true, the value is quoted and escaped.- Returns:
- this builder
-
appendRowColProperty
public JavascriptVarBuilder appendRowColProperty(int row, int col, String propertyValue, boolean quoted) appends a property with the name "rYY_cXX" where YY is the row and XX is he column.- Parameters:
row
-col
-propertyValue
-quoted
-- Returns:
-
appendText
Appends text to the var string- Parameters:
value
- the value to appendquoted
- if true, the value is quoted and escaped.- Returns:
- this builder
-
appendArrayValue
Appends an array value.- Parameters:
value
-quoted
-- Returns:
-
closeVar
Closes the array or object.- Returns:
-
toString
Returns the string for the var.
-