Cannot load data to a grid using Bean Shell Form Binder (V6 Community)

Confluence User - 22 May, 2017

Hello,

The Bean Shell Form Binder does not populate data to a grid in my form. I tried at the beginning the following standard script:

 

import org.joget.apps.form.model.*;
import org.joget.apps.form.service.*;
import java.sql.*;
import org.apache.commons.collections.SequencedHashMap;
import java.util.*;
 
public FormRowSet test() {
    FormRowSet f = new FormRowSet();
        f.setMultiRow(true);
        Class.forName("com.mysql.jdbc.Driver").newInstance();
    con = DriverManager.getConnection("jdbc:mysql://localhost:3307/jwdb?characterEncoding=UTF-8", "root", "");
 
    if(!con.isClosed()){
        
        String sql = "select id, dateCreated, dateModified, c_entryFormText from app_fd_tb_test_entry_form";
        PreparedStatement stmt = con.prepareStatement(sql);
        ResultSet rs = stmt.executeQuery();
        while (rs.next()) {
        FormRow r1 = new FormRow();
            r1.put("gridColumn1", rs.getString(1));
            r1.put("gridColumn2", rs.getString(2));
            r1.put("gridColumn3", rs.getString(3));
            r1.put("gridColumn4", rs.getString(4));
            f.add(r1);
       }
    }
    return f;
}
return test();

============================================================================

It did not work. Then I tried some static entries like the below:

 

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

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

import org.apache.commons.collections.SequencedHashMap;

import java.util.*;

 

public FormRowSet test() {

    FormRowSet f = new FormRowSet();

        f.setMultiRow(true);

         FormRow r1 = new FormRow();

            r1.put("gridColumn1", "Hello 1");

            r1.put("gridColumn2", "Hello 2");

            r1.put("gridColumn3", "Hello 3");

            r1.put("gridColumn4", "Hello 4");

            f.add(r1);

    return f;

}

return test();

=============================================================

In all cases the output is:

 

 

 

 

I don't see any errors in the logs even when I run the form as an activity in a process. What is wrong?

PS: The options of the grid is:

 

forms;beanshell;joget;binder

4


23 May, 2017
confluenceUser
confluenceUser

U r testing it in preview? I don think those load binders r executing in preview mode.

23 May, 2017
confluenceUser
confluenceUser

As I mentioned in my post, I ran it as a process activity but the result is the same: an empty grid!

24 May, 2017
confluenceUser
confluenceUser

I just tried using the code give by you in a grid. It works! I have attached here for you to check.

APP_test-1-20170524155737.jwa

import org.joget.apps.form.model.*;
import org.joget.apps.form.service.*;
import org.apache.commons.collections.SequencedHashMap;
import java.util.*;
 
public FormRowSet test() {
    FormRowSet f = new FormRowSet();
        f.setMultiRow(true);
         FormRow r1 = new FormRow();
            r1.put("gridColumn1", "Hello 1");
            r1.put("gridColumn2", "Hello 2");
            r1.put("gridColumn3", "Hello 3");
            r1.put("gridColumn4", "Hello 4");
            f.add(r1);
    return f;
}
return test();
21 Jun, 2022
confluenceUser
confluenceUser

Hello, i'm already put this code, and record success display in grid. But my problem is, when i click submit button, the record is missing. 

RELATED QUESTIONS

Your answer


To answer a question you'll need an account.

Print