Tuesday 7 January 2014

Field1_1_modified and Fld_7_lookup on the dilaog through X++ ax 2009


public void dialogPostRun(DialogRunbase _dialog)
{
    super(_dialog);

    _dialog.dialogForm().formRun().controlMethodOverload(true);
    _dialog.dialogForm().formRun().controlMethodOverloadObject(this);
}

Note, that in the code above the RunBase class itself is used as event handler (by passing this to the controlMethodOverloadObject() method), but it is possible to create a separate class for handling events.

Afterwards event handlers can be created as method with specific name: _. Control name can be found in the dialog user setup. For example, the following method will handle modify event of the first field control on the dialog:
public void fld1_1_modified()
{
    Object control;

    control = dialog.formRun().controlCallingMethod();

    if(control.modified())
    {
        info(“Modified triggered!”);
    }
 
public Object dialog(DialogRunbase _dialog, boolean _forceOnClient)
{
    DialogRunBase   dialog;
    ;

    dialog = super(_dialog, true);

    dialog.caption('@RID2885');

    dfItem = dialog.addField(typeid(ItemId));
    dfInventLoc = dialog.addField(typeid(InventLocationId));
    dfReplaceCost = dialog.addField(typeid(PdsCost));
    dfItemConfig = dialog.addField(typeid(ConfigId));
    dfColorId = dialog.addField(typeid(InventColorId), '@RID101');

    return dialog;
}
void Fld_7_lookup()

{

    Formrun fr = this.dialogModify().parmDialog();

    Object control = fr.controlCallingMethod();    

    ;

    ConfigTable::lookupConfigIdSimple(control, dfItem.value());    

}
public void dialogPostRun(DialogRunbase _dialog)

{

    ;

     super(_dialog);

    **_dialog.formRun().controlMethodOverload(true);** // Causes Stack Trace error

    _dialog.formRun().controlMethodOverloadObject(this);       

}

Mayby you should call super(_dialog) last in the dialogPostRun method.
Here is an example code for overriding the modified method. Maybe lookup has the same requirements:
public void dialogPostRun(DialogRunbase _dialog)
{
// Must be overriden to enable overriding modified method
;
    _dialog.dialogForm().formRun().controlMethodOverload(true);
    _dialog.dialogForm().formRun().controlMethodOverloadObject(this);
    _dialog.formRun().controlMethodOverload(true);
    _dialog.formRun().controlMethodOverloadObject(this);

    super(_dialog);
}
And for the custom method:
boolean Fld2_1_modified()
{
    FormStringControl c = dialog.formrun().controlCallingMethod();
    boolean ret;
    ;

    ret = c.modified(); // Super() Call the FormControl ->modified

    dlgCustomField.value(MyClass::someMethod(dlgCustomField.value())); // example

    return ret;
}
public Object dialog(DialogRunbase _dialog, boolean _forceOnClient)
{
    DialogRunBase   dialog;
    ;

    dialog = super(_dialog, true);

    dialog.caption('@RID2885');

    dfItem = dialog.addField(typeid(ItemId));
    dfInventLoc = dialog.addField(typeid(InventLocationId));
    dfReplaceCost = dialog.addField(typeid(PdsCost));
    dfItemConfig = dialog.addField(typeid(ConfigId));
    dfColorId = dialog.addField(typeid(InventColorId), '@RID101');

    return dialog;
}
Here's the call to the lookup():
void Fld_7_lookup()
{
    Formrun fr = this.dialogModify().parmDialog();
    Object control = fr.controlCallingMethod();
    ;

    ConfigTable::lookupConfigIdSimple(control, dfItem.value());
}
And this is where it keeps getting the Stack Trace error:
public void dialogPostRun(DialogRunbase _dialog)
{
    ;
     super(_dialog);
    **_dialog.formRun().controlMethodOverload(true);** // Causes Stack Trace error
    _dialog.formRun().controlMethodOverloadObject(this);   
}
Mayby you should call super(_dialog) last in the dialogPostRun method.

Here is an example code for overriding the modified method. Maybe lookup has the same requirements:
public void dialogPostRun(DialogRunbase _dialog)
{
// Must be overriden to enable overriding modified method
;
    _dialog.dialogForm().formRun().controlMethodOverload(true);
    _dialog.dialogForm().formRun().controlMethodOverloadObject(this);
    _dialog.formRun().controlMethodOverload(true);
    _dialog.formRun().controlMethodOverloadObject(this);

    super(_dialog);
}
And for the custom method:
boolean Fld2_1_modified()
{
    FormStringControl c = dialog.formrun().controlCallingMethod();
    boolean ret;
    ;

    ret = c.modified(); // Super() Call the FormControl ->modified

    dlgCustomField.value(MyClass::someMethod(dlgCustomField.value())); // example

    return ret;
}
public void dialogPostRun(DialogRunbase _dialog)
{
    super(_dialog);

    _dialog.dialogForm().formRun().controlMethodOverload(true);
    _dialog.dialogForm().formRun().controlMethodOverloadObject(this);
}

Note, that in the code above the RunBase class itself is used as event handler (by passing this to the controlMethodOverloadObject() method), but it is possible to create a separate class for handling events.

Afterwards event handlers can be created as method with specific name: _. Control name can be found in the dialog user setup. For example, the following method will handle modify event of the first field control on the dialog:
public void fld1_1_modified()
{
    Object control;

    control = dialog.formRun().controlCallingMethod();

    if(control.modified())
    {
        info(“Modified triggered!”);
    }

No comments:

Post a Comment

SQL/SSRS Interview questions I thought of blogging some SQL/SSRS interview questions.

Below are some. I will add more, when I complete the compilation 1. What is OLTP(Online Transaction Processing)? OLTP stands ...