You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Hi,

I am trying to store the form fields value to database using bean shell. But I am not able to fetch the values. I tried to get the form row using  'FormRow originalRow = rows.get(0);'. 

import org.joget.apps.form.model.*;
import org.joget.apps.form.service.*;
import java.sql.*;
import java.util.*;
public FormRowSet test() { Connection con = null; Class.forName("com.mysql.jdbc.Driver").newInstance(); con = DriverManager.getConnection("jdbc:mysql://localhost:3306/appstudio?useUnicode=true&characterEncoding=UTF-8", "root", "admin"); if(!con.isClosed()){ String query = "select id, name FROM master_country"; PreparedStatement stmt = con.prepareStatement(query); ResultSet rs = stmt.executeQuery(); FormRowSet f = new FormRowSet(); f.setMultiRow(true); while (rs.next())

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

return f;
}
}
return test();
mentioned in the knowledgebase 'http://dev.joget.org/community/display/KBv4/Store+Form+Field+Data+to+Multiple+Tables. 'But getting error 'undefined variable rows'. 

how can I get rows object ?

Please help.

Thanks,

Promod

  • No labels