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 java.util.Arrays; import org.joget.apps.app.service.AppUtil; 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; public boolean validate(Element element, FormData formData, String[] values) { boolean result = true; //get field 1 value from form data object String field1Id = "field1"; Form form = FormUtil.findRootForm(element); Element field1 = FormUtil.findElement(field1Id, form, formData); if (field1 != null) { //get value of field 1 String[] compareValues = FormUtil.getElementPropertyValues(field1, formData); //compare the value of field 2 and field 1 are equals if (!Arrays.equals(values, compareValues)) { String id = FormUtil.getElementParameterName(element); formData.addFormError(id, "Value not equal!!!!"); result = false; } } else { //ignore if the field 1 not exist } return result; } //call validate method with injected variable return validate(element, formData, values); |
...
...
Code Block |
---|
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; import org.joget.plugin.base.PluginManager; import org.joget.apps.form.model.FormLoadBinder; public FormRowSet load(Element element, String primaryKey, FormData formData) { String defaultFormDefId = "default_grid_entry"; //change this to the form id used to store default grid data String formDefId = "grid_entry"; //change this to the form id used to store grid data String foreignKey = "fk"; //change this to the foreign key FormRowSet f = new FormRowSet(); f.setMultiRow(true); // Reuse Multi Row Binder to load data PluginManager pluginManager = (PluginManager) FormUtil.getApplicationContext().getBean("pluginManager"); FormLoadBinder binder = (FormLoadBinder) pluginManager.getPlugin("org.joget.plugin.enterprise.MultirowFormBinder"); //Load from the grid table binder.setProperty("formDefId", formDefId); binder.setProperty("foreignKey", foreignKey); f = binder.load(element, primaryKey, formData); //if no grid data is retrieved, get from default table if (f == null || f.isEmpty()) { binder.setProperty("formDefId", defaultFormDefId); //set the foreign key value to empty f = binder.load(element, "", formData); } return f; } //call load method with injected variable return load(element, primaryKey, formData); |
...
Code Block |
---|
import java.util.Map; import org.joget.directory.model.User; public boolean isAuthorized(User user, Map params) { //using hash variable to get "creator" field value and escapes it with java syntax, then compare with current username return "#form.crm_account.creator?java#".equals(user.getUsername()); } //call isAuthorized method with injected variable return isAuthorized(user, requestParams); |
...
...