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

Compare with Current View Page History

« Previous Version 2 Next »

To pre-populate a single form select list from an external source, choose the select field and click 'Edit'.

Under the 'Choose Options Binder' menu, click the 'Bean Shell Form Binder' from the Options Binder select field.

Under the 'Configure Bean Shell Form Binder', enter your Bean shell script to populate the select fields. For each row you add to the FormRowSet, be sure to put the 'FormUtil.PROPERTY_VALUE' and 'FormUtil.PROPERTY_LABEL' fields into the FormRow that will be added into the FormRowSet. 

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

public FormRowSet test() {
FormRowSet f = new FormRowSet();
f.setMultiRow(true);

FormRow r1 = new FormRow();
r1.put(FormUtil.PROPERTY_VALUE, "test1");
r1.put(FormUtil.PROPERTY_LABEL, "tester1");
f.add(r1);

FormRow r2 = new FormRow();
r2.put(FormUtil.PROPERTY_VALUE, "test2");
r2.put(FormUtil.PROPERTY_LABEL, "tester2");
f.add(r2);

return f;
}

return test();

Of course, you would want to want to populate the values for the PROPERTY_LABEL and PROPERTY_VALUE from your external datasource. For more information how you would connect to a database source, see the example code within 'Pre-populate Form Fields with Data from External Source'.

  • No labels