This section describes how you customize a validation message, PM_DataItemValidate, in an existing form.
The example is using the steps described in A Simple Client Customization as base, followed by additional steps about how to extend the validation message.
A Simple Client Customization getting a customized form window named frmPersonInfo_Cust.
.
// The WindowActions event handler for dfsName private void dfsName_WindowActions(object sender, WindowActionsEventArgs e) { switch (e.ActionType) { case Ifs.Fnd.ApplicationForms.Const.PM_DataItemValidate: this.dfsName_OnPM_DataItemValidate(sender, e); break; } } private void dfsName_OnPM_DataItemValidate(object sender, WindowActionsEventArgs e) { e.Handled = true; // First, call the base implementation. e.Return = Sal.SendClassMessage(Ifs.Fnd.ApplicationForms.Const.PM_DataItemValidate, Sys.wParam, Sys.lParam); if (e.Return == Sys.VALIDATE_Ok) { // Proceed with an extended validation. if (!this.ExtendedNameValidation()) // Extended validation failed -> Return VALIDATE_Cancel. e.Return = Sys.VALIDATE_Cancel; } } protected virtual bool ExtendedNameValidation() { if (this.dfsName.Text.StartsWith("A", StringComparison.CurrentCultureIgnoreCase)) { Ifs.Fnd.Windows.Forms.FndMessageBox.Show("Names may not start with the letter 'A'!!!"); return false; } return true; }
Once the field dfsName is validated, apart from the standard logic that opens up a dialog for editing values, an extended validation will executed that will pop a message box if the entered name starts with "A" or "a".
To change the base implementation of the existing validation, the step needed are very similar to the above, with the exception skipping the "base" call by exclude the call to Sal.SendClassMessage.
... private void dfsName_OnPM_DataItemValidate(object sender, WindowActionsEventArgs e) { e.Handled = true; // First, call the base implementation. //e.Return = Sal.SendClassMessage(Ifs.Fnd.ApplicationForms.Const.PM_DataItemValidate, Sys.wParam, Sys.lParam); e.Return = Sys.VALIDATE_Ok; if (e.Return == Sys.VALIDATE_Ok) { // Proceed with an extended validation. if (!this.ExtendedNameValidation()) // Extended validation failed -> Return VALIDATE_Cancel. e.Return = Sys.VALIDATE_Cancel; } } ...
Once the field dfsName is validated, an custom validation will be made that will pop a message box if a name starts with "A" or "a". The standard validation opening a dialog box for entering values will not be run.
Note: Above example should be written much simpler, removing the initial assignment for e.Return. The purpose is simply to demonstrate the both scenarios, calling and not calling the base validation, using as little source code changes as possible.
Executing a base implementation of a message is done by calling the
Sal.SendClassMessage,
using the message constant as parameter. By doing that, the message will be
"extended". Compared to methods, this is the very same as overriding a method
named <MethodName> and first calling its
base.<MethodName>.
Excluding a base implementation of a message is done by only executing custom
logic, not calling Sal.SendClassMessage.
The message will then be "changed".