Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The business requirement is to not save the value for "Contact" when "Save As Draft" button is used to submit the form.

Thai

ในบทความนี้เราจะหารือเกี่ยวกับวิธีที่เราสามารถควบคุมการบันทึกค่าของเขตข้อมูลตามปุ่มที่คลิกบนการส่งแบบฟอร์ม ลองใช้แบบฟอร์มนี้เป็นตัวอย่าง

ข้อกำหนดทางธุรกิจคือการไม่บันทึกค่าสำหรับ "ติดต่อ" เมื่อใช้ปุ่ม "บันทึกเป็นแบบร่าง" เพื่อส่งแบบฟอร์ม

In order to address this requirement, the field "contact" needs to be in its own section. This is because form section offers permission control.

In the section where the subform is, set the permission of the section to Bean Shell Script.

Thai

เพื่อตอบสนองความต้องการนี้ฟิลด์ "ผู้ติดต่อ" จะต้องอยู่ในส่วนของตนเอง นี่เป็นเพราะ form section มีการควบคุม permission control

ในส่วนที่เป็นฟอร์มย่อยให้ตั้งค่าการอนุญาตของส่วนเป็น Bean Shell Script

We will then need to detect when the "Save As Draft" button is clicked or not to determine the next step forward.

Thai

จากนั้นเราจะต้องตรวจสอบเมื่อมีการคลิกปุ่ม "บันทึกเป็นแบบร่าง" หรือไม่เพื่อกำหนดขั้นตอนต่อไป

Code Block
languagejava
//the following will return false (hash not empty against empty string) if "save as draft" button is clicked on form submission, othwerise, it will return true (form loading)
return "#requestParam.saveAsDraft?java#".equals("");

...

With this, the value "c" will only gets replaced with user's input value when "Complete" button is hit, otherwise, it will stays as it is.

Thai

เมื่อคลิกปุ่ม "บันทึกเป็นแบบร่าง" ตัวแปรแฮชในรหัสด้านบนจะถูกวิเคราะห์เป็น "บันทึกเป็นแบบร่าง" ดังนั้นการทำให้ฟังก์ชันเท่ากับกลับเป็นเท็จ ในการใช้งานปลั๊กอินที่ได้รับอนุญาตโดยการคืนค่าเป็นเท็จฟิลด์แบบฟอร์มภายในส่วนของมันจะไม่ถูกนำมาใช้สำหรับการตรวจสอบความถูกต้องอีกต่อไป (การดำเนินการตัวตรวจสอบความถูกต้องของแบบฟอร์ม) และการบันทึก

สคริปต์เดียวกันสามารถวางในสิทธิ์ของส่วนฟอร์มฟอร์มย่อยหรือในสิทธิ์ของฟอร์มย่อยได้เช่นกัน

ด้วยสิ่งนี้ค่า "c" จะถูกแทนที่ด้วยค่าอินพุตของผู้ใช้เมื่อกดปุ่ม "เสร็จสิ้น" มิฉะนั้นจะยังคงอยู่เหมือนเดิม