Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
...
Code Block | ||||
---|---|---|---|---|
| ||||
import org.joget.apps.form.model.FormRow; import org.joget.apps.form.model.FormRowSet; import org.joget.apps.app.service.AppUtil; import org.joget.plugin.base.PluginManager; import org.joget.apps.form.model.FormStoreBinder; import org.joget.workflow.model.service.WorkflowManager; import org.joget.apps.form.model.Element; import org.joget.apps.form.model.Form; import org.joget.apps.form.model.FormData; import org.joget.apps.form.service.FormUtil; String formDefId = "teamVote"; //change this to the form id used to load grid data String foreignKey = "feedback"; //change this to the foreign key field id // Reuse Multi Row Binder to load data PluginManager pluginManager = (PluginManager) AppUtil.getApplicationContext().getBean("pluginManager"); WorkflowManager workflowManager = (WorkflowManager) AppUtil.getApplicationContext().getBean("workflowManager"); FormStoreBinder binder = (FormStoreBinder) pluginManager.getPlugin("org.joget.plugin.enterprise.MultirowFormBinder"); //Load from the grid table binder.setProperty("formDefId", formDefId); binder.setProperty("foreignKey", foreignKey); Form form = FormUtil.findRootForm(element); Element field = FormUtil.findElement("team_vote", form, formData); FormRow row = rows.get(0); FormRowSet f = new FormRowSet(); f.setMultiRow(true); String vote = row.get("team_vote"); String[] votes = vote.split(";"); for(String v: votes){ if(!v.isEmpty()){ FormRow r = new FormRow (); r.setProperty("member", v); f.add(r); } } return binder.store(field, f, formData); |