Hi,
I found a useful thing from the dev. cook book ax 2009.
To override the dialog fields (controls) event from the dynamically created dialogs.
Usage of dialogSelectCtrl() sometimes might appear a bit limited as this method is only
invoked when the dialog control loses its focus. No other events can be controlled, and it can
become messy if more controls needs to be processed. Actually, this method is called from
the selectControl() of the form, which is used as a base for the dialog.
As mentioned earlier, dialogs created using the Dialog class are actually forms, which are
dynamically created during runtime. So in order to extend event handling functionality on
dialogs, we should utilize form event handling features.
The Dialog class does not provide direct access to form event handling functions, but we can
easily access the form object within the dialog. Although we cannot create the usual event
handling methods on runtime form controls, we can override this behavior. Let's modify the
previous example to include more events. We will add an event on the second tab page, which
is triggered once the page is activated. First, we have to override the dialogPostRun()
method on the Class1 class:
public void dialogPostRun(DialogRunbase dialog)
{;
dialog.formRun().controlMethodOverload(true);
dialog.formRun().controlMethodOverloadObject(this); //this refers the current class object
super(dialog);
}
Here, we enable event overriding on the form after it is fully created and is ready for
displaying on the screen. We also pass the CustSelect object as argument for the
controlMethodOverloadObject() to make sure that form "knows" where overridden
events are located.
Next, we have to create the method that overrides the tab page event:
void TabPg_2_pageActivated()
{;
info('Tab page activated');
}
The method name consists of the control name and event name joined with an underscore.
But before creating such methods, we first have to get the name of the runtime control. This
is because the dialog form is created dynamically, and Dynamics AX defines control names
automatically without allowing the user to choose them. In this example, I have temporary
added the following code to the bottom of dialog(), which displayed the name of the
Details tab page control when the class was executed:
info(tabDetails.name());
Now, run the class again, and select the Details tab page. The message should be displayed
in the Infolog.
Hope it helps.
Regards,
/Ashlesh