Thursday, February 10, 2022

Overload a method for a new button in Form extension

 This can be used as a copy-paste pattern, when you need to change a standard method for new form controls added as a form extensions.

At the form initialization step we can overload any form control methods with registerOverrideMethod.

public final class my<FormName>_MyNewButton_Extension
   public void init()
        next init();
		// MyNewButton button added in an extension to <FormName>
        FormButtonControl myButton =<FormName>, myNewButton));
		// Here we can overload its standard clicked() method in run-time		
        myButton.registerOverrideMethod(methodStr(FormButtonControl, clicked), formMethodStr(<FormName>, myNewButtonClicked), this);

    public void myNewButtonClicked(FormButtonControl _sender)
		<run some logic>

Check this article for more complicated scenario

No comments: