25.04.2007, 22:23 | #1 |
Участник
|
Kashperuk Ivan: Dynamics AX Tutorials - Tutorial 2 - Classes\Box
Источник: http://kashperuk.blogspot.com/2007/0...utorial-2.html
============== Here is a small project demonstrating capabilities of the class BOX in Dynamics AX. Specifically, the following is covered in this tutorial:
The class contains a number of methods that can be extended with new ones (as shown below). All the methods are static and have the keyword client in the declaration, which forces the code in them to be executed on the client side. The most commonly used methods of this class are:
---------------------- The rest of the methods is rarely found in the application code, and is suited for specific situations where you need to provide the user with the option of choosing from more options. (for example, when imporing a project, you see a dialog created by the method box::yesAllNoAllCancel(); The implementation of these methods is very much alike: (example mentioned above) X++: client static DialogButton yesAllNoAllCancel(str _text, //message DialogButton _defaultButton, //default dialog button str _title = "@SYS11132") //dialogTitle { Form form; Args args; Object formRun; ; args = new Args(); args.name(formStr(SysBoxForm)); //form SysBoxForm is used to show the message formRun = classFactory.formRunClass(args); //creating a FormRun object formRun.init(); //calling init of the form formRun.setTitle(_title); //setting title of the form (caption) formRun.setText(_text); //setting message formRun.setType(DialogBoxType::YESTOALLNOTOALLBOX); //setting the type of the form formRun.setDefaultButton(_defaultButton); //setting the default button formRun.run(); //calling run of the form formRun.wait(); //waiting for user action return formRun.dialogButton(); //returing the user selection } Args args - not discusses here (used to specify the name of the form that is being created) Object formRun - that is the actual object of the form being created. You might have noticed that it is of type Object and not FormRun. (using the base type) This is done on purpose, as there is no compile-time validationg of methods actually existing on the form. If the method doesn't exist, you will receive a runtime error, which is not really appropriate in a live environment. So in your code you should chech that the methods being called do actullay exist. (Global method formHasMethod can be used for this purpose) After the form is initialized and all the setMethods() are called, the Run() method is called. This method executes the form and shows it on the screen. After the Run Method we see a call to formRun.wait(); This method notifies the RunTime that the code execution should stop here and wait until the form is closed. (if this method is used on a form to call a child form, the parent form cannot be closed before the child form) [Note: The alternative method here is the detach method (behavior of MenuItem calls)] After the user closes the form, the dialogButton method on the form is called to return the selected value. [Note: Notice, that the methods on the form are still accessible, even though the form is already closed by the user. This happens because the formRun object is not yet destroyed] ----------------- I added another method to the box class - yesNoWaitForm. It opens a form that looks kinda cooler than the standard forms, because it has the option of autoclosing after a set period of time. Well, everyone can find his own uses for this form. The form name is Dev_SysBoxForm and it is an almost complete duplicate of the system SysBoxForm form. The only big difference is that this form is set modal, and that the text of the default button is appended with the remaining amount of time before the form is autoclosed. [Note: SetTimeOut method is used, which is not covered in this tutorial] There were differences in implementation (compared to the sytem form SysBoxForm). The main are listed below:
Источник: http://kashperuk.blogspot.com/2007/0...utorial-2.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
|