Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
Hello All,
I have a question about select box with beanshell, below is the beanshell code of select box.
and it give me the error logs as below, but if I change the SQL clause in beanshell code from "SELECT id,name FROM app_userview" to "SELECT id,name FROM app_datalist", then it's functional,
Would you please help me to find out how to solve this issue?
Thanks
Gene
import org.joget.apps.form.service.*; import org.joget.apps.app.service.AppUtil; import java.sql.*; import org.apache.commons.collections.SequencedHashMap; import java.util.*; import javax.sql.DataSource; import org.joget.apps.app.model.AppDefinition; public FormRowSet getData() { Connection con=null; PreparedStatement stmt = null; ResultSet rs = null; String sql = ""; FormRowSet f = new FormRowSet(); f.setMultiRow(true); DataSource ds = (DataSource) AppUtil.getApplicationContext().getBean("setupDataSource"); con = ds.getConnection(); if(!con.isClosed()){ String sql = "SELECT id,name FROM app_userview"; stmt = con.prepareStatement(sql); //stmt.setString(1,orgId); rs = stmt.executeQuery(); FormRow r1 = new FormRow(); r1.put(FormUtil.PROPERTY_VALUE, ""); r1.put(FormUtil.PROPERTY_LABEL, ""); f.add(r1); while (rs.next()) { FormRow r2 = new FormRow(); //String id = rs.getString("id"); //String userviewName = rs.getString("name"); r2.put(FormUtil.PROPERTY_VALUE,rs.getString(1)); r2.put(FormUtil.PROPERTY_LABEL,rs.getString(2)); f.add(r2); } rs.close(); stmt.close(); con.close(); } return f; } return getData();
ERROR 04 May 2015 00:01:28 org.joget.apps.form.lib.BeanShellFormBinder - Error executing script Sourced file: inline evaluation of: ``import org.joget.apps.form.model.*; import org.joget.apps.form.service.*; import . . . '' : Method Invocation r1.put : at Line: 40 : in file: inline evaluation of: ``import org.joget.apps.form.model.*; import org.joget.apps.form.service.*; import . . . '' : r1 .put ( FormUtil .PROPERTY_LABEL , appName ) Target exception: java.lang.NullPointerException at bsh.BSHMethodInvocation.eval(Unknown Source) at bsh.BSHPrimaryExpression.eval(Unknown Source) at bsh.BSHPrimaryExpression.eval(Unknown Source) at bsh.BSHBlock.evalBlock(Unknown Source) at bsh.BSHBlock.eval(Unknown Source) at bsh.BSHBlock.eval(Unknown Source) at bsh.BSHWhileStatement.eval(Unknown Source)