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.sqlorg.joget.apps.app.service.*;
import orgjava.apache.commons.collections.SequencedHashMapsql.*;
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 fcon.close();
}
return getRecords()f;


Store Binder -> Bean Shell Form Binder

...

Correct Grid design should look like this:

 


Part Example of a simple load binder beanshell script :

Code Block
languagejava
import org.joget.apps.form.model.FormRow;
import org.joget.apps.form.model.FormRowSet;

FormRowSet f = new FormRowSet();
f.setMultiRow(true);

FormRow r1 = new FormRow();
r1.put("gridColumn1", your_value);
r1.put("gridColumn2", your_value);
r1.put("gridColumn3", your_value);
f.add(r1);

FormRow r2 = new FormRow();
r2.put("gridColumn1", your_value);
r2.put("gridColumn2", your_value);
r2.put("gridColumn3", your_value);
f.add(r2);
 
return f;

...

Related Tutorial

 

...