Chain of Command (CoC) enables strongly typed extension capabilities of public and protected methods. It is an amazing piece of development capability that allows technical consultants to extend the application avoiding over-layering.
We can write the COC’s for individual objects by specifying the object name in the [ExtensionOf(ObjectName)] on the class header.
✓ For Class COC we use [ExtensionOf(classStr(ClassName))]
✓ For Form COC we use [ExtensionOf(formStr(FormName))]
✓ For FormControl COC we use [ExtensionOf(formControlStr(FormName,FormControlName))]
✓ For FormDataSource COC we use [ExtensionOf(formDatasourceStr(FormName,FormDSName))]
✓ For FormDataFieldStr COC we Use [ExtensionOf(formDataFieldStr(FormName,FormDSName,Field))]
✓ For Table COC we use [ExtensionOf(tableStr(TableName))]
✓ For Data Entity COC we use [ExtensionOf(tableStr(DataEntityName))]
COC for Form Data Field:
[ExtensionOf(formDataFieldStr(SalesTable, SalesLine, ItemId))]
final class SalesTable_SalesLineItemId_Extension
{
public void modified()
{
FormDataObject formDataObject = any2Object(this) as FormDataObject;
FormDataSource formDataSource = formDataObject.datasource();
SalesLine salesLine;
next modified();
salesLine = formDataSource.cursor();
salesLine.Name = InventTable::find(salesLine.ItemId).itemName();
}
}
Event handler for Form Data Field
[FormDataFieldEventHandler(formDataFieldStr(SalesTable, SalesLine,
ItemId), FormDataFieldEventType::Modified)]
public static void ItemId_OnModified(FormDataObject sender,
FormDataFieldEventArgs e)
{
FormRun formRun = sender.datasource().formRun();
SalesLine salesLine = formRun.dataSource(formdatasourcestr(SalesTable, SalesLine)).cursor();
formRun = sender.datasource().formRun();
}
COC for Form Datasource:
[ExtensionOf(formDatasourcestr(SalesTableListPage,SalesTable))]
final class TM_SalesTable_DataSource_Extension
{
public int active()
{
int ret = next active();
SalesTable SalesTable_ds = this.cursor();
if(SalesTable_ds.SalesStatus == SalesStatus::Invoiced)
{
this.formRun().design().controlName(formControlStr(SalesTableListPage,Form ButtonControl1)).enabled(true);
}
else
{
this.formRun().design().controlName(formControlStr(SalesTableListPage,Form ButtonControl1)).enabled(false);
}
return ret;
}
}
Event handler for Form Datasource:
[FormDataSourceEventHandler(formDataSourceStr(SalesTableListPage,
SalesTable), FormDataSourceEventType::Activated)]
public static void SalesTable_OnActivated(FormDataSource sender,
FormDataSourceEventArgs e)
{
SalesTable SalesTable = sender.cursor() as SalesTable;
FormRun element = sender.formRun();
FormCheckBoxControl SalesTable_TMCreditLimitChecked =
element.design(0).controlName("SalesTable_TMCreditLimitChecked");
FormCheckBoxControl SalesTable_TMCreditLimitExceeded =
element.design(0).controlName("SalesTable_TMCreditLimitExceeded");
FormMenuButtonControl WorkflowActionBarButtonGroup =
element.design().controlName("WorkflowActionBarButtonGroup");
if(SalesTable.SalesStatus == SalesStatus::Invoiced)
{
sender.formRun().design().controlName(formControlStr(SalesTableListPage,FormButtonControl1)).enabled(true);
}
else
{
sender.formRun().design().controlName(formControlStr(SalesTableListPage,FormButtonControl1)).enabled(false);
}
}
COC for Form:
[ExtensionOf(formStr(SalesTable))]
final class TM_SalesTable_Form_Extension
{
public void init()
{
FormRun formRun = this as FormRun;
FormDataSource SalesTable_DS = formRun.datasource(FormDatasourceStr(SalesTable,SalesTable));
SalesTable _salestable = SalesTable_DS.Cursor();
FormControl custAccount =
formRun.design().ControlName(FormControlStr(SalesTable,SalesLine_itemid));
next init();
}
}
Event Handler for Form:
[PostHandlerFor(formStr(SalesTable), formMethodStr(SalesTable, init))]
public static void SalesTable_Post_init(XppPrePostArgs args)
{
FormRun form = _args.getThis();
FormDesign design = form.design();
FormControl itemid = design.controlName(formControlStr(SalesLine,Salesline_itemid));
}
Event Handler for Class:
No comments:
Post a Comment