Hi everybody,

I need some help. I am trying to fill a select box with data from native database. That is the scenario: I have a table with data about departments and i want to populate my select box with values from a column in this table.

I don't know how.

  • No labels

1 Comment

  1. In the form builder you have to choose to your selectBox Options Binder: Bean Shell From Binder with text like this:

    import org.joget.apps.form.model.*;

    import org.joget.apps.form.service.*;

    import java.sql.*;

    import java.util.*;

    Connection con = null;

    Class.forName("com.mysql.jdbc.Driver").newInstance();

    con = DriverManager.getConnection("jdbc:mysql://localhost:3306/DBName?useUnicode=true&characterEncoding=UTF-8", "Username", "Userpass");

    if(!con.isClosed()){

    PreparedStatement stmt = con.prepareStatement("select name, email from view_Person");

    ResultSet rs = stmt.executeQuery();

    FormRowSet f = new FormRowSet();

    f.setMultiRow(true);

    while (rs.next())

    Unknown macro: { FormRow vRow = new FormRow(); vRow.put(FormUtil.PROPERTY_VALUE, rs.getString(2)); vRow.put(FormUtil.PROPERTY_LABEL, rs.getString(1)); f.add(vRow);}

     f.add(vRow);

      }

    return f;

     }

    Using beanshell options binder to populate a select list