Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
...
Thai |
---|
มีไว้เพื่ออะไร? |
English |
---|
Joget Workflow provided Bean Shell implementation as several Plugin Types. Please refer to usages section. |
Thai |
---|
Joget Workflow ให้การใช้งาน Bean Shell เป็นปลั๊กอินหลายประเภท โปรดดู usages |
BeanShell is a small, embeddable Java source interpreter with object scripting language features written in Java.
Thai |
---|
BeanShell เป็นล่าม Java ขนาดเล็กที่สามารถฝังตัวได้พร้อมคุณสมบัติภาษาสคริปต์วัตถุที่เขียนด้วยภาษาจาวา |
BeanShell dynamically executes standard Java syntax in runtime.
Thai |
---|
BeanShell เรียกใช้งานไวยากรณ์ Java มาตรฐานแบบไดนามิกในรันไทม์ |
By using BeanShell Plugin, you can type in valid Java codes in plugin configuration and the statements will be executed when the plugin is triggered.
Thai |
---|
โดยใช้ BeanShell Plugin คุณสามารถพิมพ์รหัส Java ที่ถูกต้องในการกำหนดค่าปลั๊กอินและคำสั่งจะถูกดำเนินการเมื่อมีการเรียกใช้ปลั๊กอิน |
No compilation cycle is needed.
Thai |
---|
ไม่จำเป็นต้องมีวงจรการรวบรวม |
...
Code Block | ||
---|---|---|
| ||
import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import javax.sql.DataSource; 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.commons.util.LogUtil; public FormRowSet load(Element element, String username, FormData formData) { FormRowSet rows = new FormRowSet(); if (username != null && !username.isEmpty()) { Connection con = null; try { // retrieve connection from the default datasource DataSource ds = (DataSource)AppUtil.getApplicationContext().getBean("setupDataSource"); con = ds.getConnection(); // execute SQL query if(!con.isClosed()) { PreparedStatement stmt = con.prepareStatement("SELECT username, firstName, lastName, email from dir_user where username=?"); stmt.setObject(1, username); ResultSet rs = stmt.executeQuery(); while (rs.next()) { FormRow row = new FormRow(); System.out.println(rs.getObject("username") ); row.setProperty("username", (rs.getObject("username") != null)?rs.getObject("username").toString():""); row.setProperty("firstName", (rs.getObject("firstName") != null)?rs.getObject("firstName").toString():""); row.setProperty("lastName", (rs.getObject("lastName") != null)?rs.getObject("lastName").toString():""); row.setProperty("email", (rs.getObject("email") != null)?rs.getObject("email").toString():""); rows.add(row); //we add break; so that it stops iterating after the first result is returned break; } } } catch(Exception e) { LogUtil.error("Sample app - Form 1", e, "Error loading user data in load binder"); } finally { //always close the connection after used try { if(con != null) { con.close(); } } catch(SQLException e) {/* ignored */} } } return rows; } //call load method with injected variable return load(element, primaryKey, formData); |
...
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); |
Textfield / Textarea length not exceeding 500 characters
Code Block | ||||
---|---|---|---|---|
| ||||
import java.util.Arrays;
import org.joget.apps.form.model.Element;
import org.joget.apps.form.model.FormData;
import org.joget.apps.form.service.FormUtil;
if(values[0].length() > 500){
String id = FormUtil.getElementParameterName(element);
formData.addFormError(id, "Value cannot be longer than 500 characters. You have entered " + values[0].length() + " characters.");
return false;
}else{
return true;
} |
Field value does not exceed 500 in numerical value
Code Block | ||||
---|---|---|---|---|
| ||||
import java.util.Arrays; import org.joget.apps.form.model.Element; import org.joget.apps.form.model.FormData; import org.joget.apps.form.service.FormUtil; String id = FormUtil.getElementParameterName(element); String amount = ""; if(values.length > 0){ amount = values[0]; } if(amount.isEmpty()){ formData.addFormError(id, "Value not equal!!!!Please key in a amount."); result =return false; }else{ float amountF } = Float.parseFloat(amount); } else if(amountF >=500){ //ignore if the field 1 not existformData.addFormError(id, "Amount cannot be more than 500."); } return resultfalse; } //call validate method with injected variable } } return validate(element, formData, values)true; |
...
datalist - Datalist object of the current datalist (org.joget.apps.datalist.model.Datalist)
Thai |
---|
datalist - วัตถุ datalist ของ datalist ปัจจุบัน (org.joget.apps.datalist.model.Datalist) |
column - The current datalist column object (org.joget.apps.datalist.model.DataListColumn)
Thai |
---|
column - วัตถุคอลัมน์ datalist ปัจจุบัน (org.joget.apps.datalist.model.DataListColumn) |
row - row Object of current record row in the datalist.
To retrieve the property value from Object row, use this service method: DataListService.evaluateColumnValueFromRow(Object row, String propertyName)
Thai |
---|
row - row วัตถุของแถวเร็กคอร์ดปัจจุบันใน datalist |
value - value of the current row as String
Thai |
---|
value - ค่าของแถวปัจจุบันเป็น String |
...