1
0
-1

i create 2 form and used bean shell store binder to store data in both form. But bean shell store binder in sub form not working.

main form bean shell store binder

import java.sql.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.util.*;
import javax.sql.DataSource;
import org.apache.commons.collections.SequencedHashMap;
import org.joget.apps.app.service.AppUtil;
import org.joget.apps.form.lib.*;
import org.joget.apps.form.model.*;
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.model.FormStoreBinder;
import org.joget.apps.form.service.*;
import org.joget.apps.form.service.FormUtil; 
import org.joget.commons.util.LogUtil;
import org.joget.commons.util.UuidGenerator;
import org.joget.plugin.base.PluginManager;

public FormRowSet store(Element element, FormRowSet rows, FormData formData) {

  //check the rows is not empty before store it
  if (rows != null && !rows.isEmpty()) {
    //Get the submitted data
    FormRow row = rows.get(0);

    // backup old datas to history table
    Form parentForm = FormUtil.findRootForm(element);
    String pk = parentForm.getPrimaryKeyValue(formData);

    System.out.println(" ");
    System.out.println("app_fd_demoMain ID = " + pk);
    System.out.println(" ");

    //Reuse Workflow Form Binder to store data
    PluginManager pluginManager = (PluginManager) AppUtil.getApplicationContext().getBean("pluginManager");
    FormStoreBinder binder = (FormStoreBinder) pluginManager.getPlugin("org.joget.apps.form.lib.WorkflowFormBinder");
    binder.store(element, rows, formData);
  }

  return rows;
}

//call store method with injected variable
return store(element, rows, formData);

and in sub form

import java.sql.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.util.*;
import javax.sql.DataSource;
import org.apache.commons.collections.SequencedHashMap;
import org.joget.apps.app.service.AppUtil;
import org.joget.apps.form.lib.*;
import org.joget.apps.form.model.*;
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.model.FormStoreBinder;
import org.joget.apps.form.service.*;
import org.joget.apps.form.service.FormUtil; 
import org.joget.commons.util.LogUtil;
import org.joget.commons.util.UuidGenerator;
import org.joget.plugin.base.PluginManager;

public FormRowSet store(Element element, FormRowSet rows, FormData formData) {

  //check the rows is not empty before store it
  if (rows != null && !rows.isEmpty()) {
    //Get the submitted data
    FormRow row = rows.get(0);

    // backup old datas to history table
    String pk = element.getPrimaryKeyValue(formData);

    System.out.println(" ");
    System.out.println("app_fd_demo ID = " + pk);
    System.out.println(" ");

    //Reuse Workflow Form Binder to store data
    PluginManager pluginManager = (PluginManager) AppUtil.getApplicationContext().getBean("pluginManager");
    FormStoreBinder binder = (FormStoreBinder) pluginManager.getPlugin("org.joget.apps.form.lib.WorkflowFormBinder");
    binder.store(element, rows, formData);
  }

  return rows;
}

//call store method with injected variable
return store(element, rows, formData);
after submit update form. i can see

app_fd_demoMain ID = xxxxxxx

in windows command but can not see "app_fd_demo ID = "

may i can use bean shell store binder in subform or refer all primary key of subform?
    CommentAdd your comment...

    1 answer