Class JavascriptVarBuilder

java.lang.Object
org.primefaces.extensions.util.JavascriptVarBuilder

public class JavascriptVarBuilder extends Object
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 Details

    • JavascriptVarBuilder

      public JavascriptVarBuilder(String varName, boolean isObject)
      Constructs an instance of the builder.
      Parameters:
      varName - the variable name
      isObject - 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 name
      propertyValue - the property value
      quoted - 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

      public JavascriptVarBuilder appendText(String value, boolean quoted)
      Appends text to the var string
      Parameters:
      value - the value to append
      quoted - if true, the value is quoted and escaped.
      Returns:
      this builder
    • appendArrayValue

      public JavascriptVarBuilder appendArrayValue(String value, boolean quoted)
      Appends an array value.
      Parameters:
      value -
      quoted -
      Returns:
    • closeVar

      public JavascriptVarBuilder closeVar()
      Closes the array or object.
      Returns:
    • toString

      public String toString()
      Returns the string for the var.
      Overrides:
      toString in class Object