BeanShell Display Column

BeanShell Display Column allows BeanShell integration in a List, which allows you to write custom Java code to create custom displays.

Add a BeanShell Display Column

To add a BeanShell Display Column in a List follow the steps below:

  1. It can be found in a List labeled BeanShell under the Display Column
    Not to be confused with BeanShell Action.
  2. Drag and drop into the List, and click on it to configure it.

Configure BeanShell Display Column

When configuring the Beanshell Display Column, you will see the following menu on the right side.

Configure the following properties:

  • Label: A custom label for the BeanShell Display Column element. The default value is "BeanShell".
  • ID: The ID of the BeanShell Display Column element.
  • Script: Custom script in Java.

Usage examples

You can use the BeanShell Display Column for different cases. such as:

  1. Display a custom string: Input return "flower"; in the Script field.You will get the result in the image below:

    List of Injected Variables Used for Samples 2 and 3:

    • BeanShellColumn column
    • DataList datalist
    • Object row
    • int index
  2. Display Number Row in Roman Numerals: Input the code block below in the Script field.

    int decimalNumber = index + 1;
     
    int[] values = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
    String[] romanLetters = {"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"};
     
    StringBuilder romanNumber = new StringBuilder();
     
    for(int i = 0; i < values.length; i++){ 
        while(decimalNumber >= values[i]){
            decimalNumber = decimalNumber - values[i];
            romanNumber.append(romanLetters[i]);
        }
    }
     
    return romanNumber;

    The result is the following.

  3. Display Number Row with Conditional Prefix: Input the code block below in the Script field.

    int rowNumber = index + 1;
     
    int determinant = rowNumber % 2;
     
    if (determinant == 0){
        return "Even " + rowNumber;
    }
    else if (determinant != 0){
        return "Odd " + rowNumber;
    }
    else{
        return "Error";
    }

    The result is the following.

Created by Marcos Last modified by Aadrian on Dec 13, 2024