Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Load Binder -> Bean Shell Form Binder

Code Block
languagejava
import org.joget.apps.form.model.*;
import org.joget.apps.form.service.*;
import java.sql.*;
import org.apache.commons.collections.SequencedHashMap;
import java.util.*;
import javax.sql.DataSource;

public FormRowSet getRecords() {
	FormRowSet f = new FormRowSet();
    f.setMultiRow(true);
    
//Get Joget's current datasource configs
    DataSource ds = (DataSource) AppUtil.getApplicationContext().getBean("setupDataSource");

    con = ds.getConnection();

	if (!con.isClosed()) {
		//Get the URL parameter
		String recordId = "#requestParam.id#";
 
		//Here you can query from one or multiple tables using JOIN etc
		String sql = "SELECT * FROM your_table_name WHERE id=?";
		PreparedStatement stmt = con.prepareStatement(sql);
		stmt.setString(1, recordId);
 
		//Execute the SELECT SQL statement
		ResultSet rs = stmt.executeQuery();
		
		//Get value from columns of record(s)
		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));
			f.add(r1);
	   }
	}

	return f;
}
return getRecords();


Store Binder -> Bean Shell Form Binder

...

Correct Grid design should look like this:

 

Part Example of a simple load binder beanshell script :

...