...
เปิด maven project ของคุณด้วย IDE ที่ชื่นชอบ. เราแนะนำ NetBeans.
7. เริ่มโค้ด!
a.
...
การขยาย abstract class
...
ของประเภทปลั๊กอิน
สร้าง "BeanShellHashVariable" ภายใต้ class "org.joget.tutorial" package.
...
จากนั้น ขึ้นอยู่กับเอกสาร Hash Variable Plugin ,เราจะต้องขยาย org.joget.apps.app.model.DefaultHashVariablePlugin abstract class.
b.
...
การดำเนินการของ abstract methods
...
ทั้งหมด
ให้เราใช้วิธีนามธรรมทั้งหมด เราจะใช้วิธี Let us implement all the abstract methods. We will be using AppPluginUtil.getMessage method to support i18n and using constant variable เพื่อสนับสนุน i18n และการใช้ตัวแปร MESSAGE_PATH for message resource bundle directory.แบบคงที่สำหรับไดเร็กทอรีบันเดิลทรัพยากรข้อความ
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
package org.joget.tutorial; import org.joget.apps.app.model.DefaultHashVariablePlugin; import org.joget.apps.app.service.AppPluginUtil; public class BeanShellHashVariable extends DefaultHashVariablePlugin { private final static String MESSAGE_PATH = "messages/BeanShellHashVariable"; public String getName() { return "BeanShellHashVariable"; } public String getVersion() { return "5.0.0"; } public String getClassName() { return getClass().getName(); } public String getLabel() { //support i18n return AppPluginUtil.getMessage("org.joget.tutorial.BeanShellHashVariable.pluginLabel", getClassName(), MESSAGE_PATH); } public String getDescription() { //support i18n return AppPluginUtil.getMessage("org.joget.tutorial.BeanShellHashVariable.pluginDesc", getClassName(), MESSAGE_PATH); } public String getPropertyOptions() { //Hash variable plugin do not support property options return ""; } public String getPrefix() { return "beanshell"; } public String processHashVariable(String variableKey) { throw new UnsupportedOperationException("Not supported yet."); } } |
...