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

beanshell code in select box
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)
  • No labels

3 Comments

  1. Hi there,

    I'm getting different errors though. Please check.

    ERROR 06 May 2015 09:48:22 org.joget.apps.form.lib.BeanShellFormBinder  - Error executing script
    Sourced file: inline evaluation of: ``import org.joget.apps.form.service.*; import org.joget.apps.app.service.AppUtil; .
     . . '' : Class: FormRowSet not found in namespace : at Line: 9 : in file: inline evaluation of: ``import org.joget.apps
    .form.service.*; import org.joget.apps.app.service.AppUtil; . . . '' : FormRowSet

    You will need to include these in your coding.

    import org.joget.apps.form.model.FormRow;
    import org.joget.apps.form.model.FormRowSet;

    Hope this helps.

    Thanks.

    Hugo

    1. Hi Hugo,

      I tried but failed again, would you please help me check it again.

      Thanks

      Gene

      ERROR 06 May 2015 10:26:54 org.joget.apps.form.lib.BeanShellFormBinder  - Error executing script
      Sourced file: inline evaluation of: ``import org.joget.apps.form.model.FormRow; import org.joget.apps.form.model.FormR . . . '' : Method Invocation r2.put : at Line: 34 : in file: inline evaluation of: ``import org.joget.apps.form.model.FormRow; import org.joget.apps.form.model.FormR . . . '' : r2 .put ( FormUtil .PROPERTY_LABEL , rs .getString ( 2 ) )
      Target exception: java.lang.NullPointerException
      	at bsh.BSHMethodInvocation.eval(Unknown Source)
      	at bsh.BSHPrimaryExpression.eval(Unknown Source)
      	at bsh.BSHPrimaryExpression.eval(Unknown Source)
  2. Hi Hugo,

    I tried but failed again, would you please help me check it again.

    Thanks

    Gene

    ERROR 06 May 2015 10:26:54 org.joget.apps.form.lib.BeanShellFormBinder  - Error executing script
    Sourced file: inline evaluation of: ``import org.joget.apps.form.model.FormRow; import org.joget.apps.form.model.FormR . . . '' : Method Invocation r2.put : at Line: 34 : in file: inline evaluation of: ``import org.joget.apps.form.model.FormRow; import org.joget.apps.form.model.FormR . . . '' : r2 .put ( FormUtil .PROPERTY_LABEL , rs .getString ( 2 ) )
    Target exception: java.lang.NullPointerException
    	at bsh.BSHMethodInvocation.eval(Unknown Source)
    	at bsh.BSHPrimaryExpression.eval(Unknown Source)
    	at bsh.BSHPrimaryExpression.eval(Unknown Source)