how to use options ---BEAN SHELL Binder in the list????

Confluence User - 04 Jul, 2016

I mean I want use the plugin in the list,what should I do?why it does not work?

 

 

import org.joget.apps.app.service.AppUtil;
import org.joget.apps.form.model.Element;
import org.joget.apps.form.model.FormData;
import org.joget.apps.form.model.FormRow;
import org.joget.apps.form.model.FormRowSet;
import org.joget.apps.form.service.FormUtil;


public FormRowSet load(Element element, String username, FormData formData) {
FormRowSet rows = new FormRowSet();
FormRow option = new FormRow();
option.setProperty(FormUtil.PROPERTY_VALUE, '1111');
option.setProperty(FormUtil.PROPERTY_LABEL, '1111');
rows.add(option);
return rows;
}

//call load method with injected variable
return load(element, primaryKey, formData);

datalists

3


04 Jul, 2016
confluenceUser
confluenceUser

I'm not sure on what you are trying to achieve. There is no need for you to code in Java for this plugin.

Please see the screenshots in the plugin page itself. https://marketplace.joget.org/jw/web/userview/mp/mpp/_/vad?id=jdbc_options_binder-v1

Hope this helps.

05 Jul, 2016
confluenceUser
confluenceUser

I wrote wrong title, the JDBC Binder does not work in the list 。

05 Jul, 2016
confluenceUser
1
confluenceUser

hello,

you can try this code for select option in list builder use bean shell

 

import org.joget.apps.form.model.*;

import org.joget.apps.form.service.*;

import org.joget.apps.app.service.*;

import org.joget.apps.form.model.*;

import org.joget.apps.form.service.*;

import java.sql.*;

import java.util.*;

import javax.sql.DataSource;

 

public FormRowSet getData() {

 

    results = new FormRowSet();

    Connection con = null;

        try {

            DataSource ds = (DataSource) AppUtil.getApplicationContext().getBean("setupDataSource");

            con = ds.getConnection();

            if(!con.isClosed()){

                String sql = "SELECT id,c_name FROM app_fd_sm_plant";

                PreparedStatement stmt = con.prepareStatement(sql);

                ResultSet rs = stmt.executeQuery();

                while (rs.next()) {

                    FormRow row = new FormRow();

                    row.put(FormUtil.PROPERTY_VALUE, rs.getString(1));

                    row.put(FormUtil.PROPERTY_LABEL, rs.getString(1) + " - " + rs.getString(2));

                    results.add(row);

                }

            }

 

        } catch(Exception ex) {

            System.err.println("Exception: " + ex.getMessage());

        } finally {

            try {

                if(con != null)

                    con.close();

            } catch(SQLException e) {}

        }

 

    return results;

}

 

return getData();

 

 

RELATED QUESTIONS

Your answer


To answer a question you'll need an account.

Print