super() 是从哪里调用的?

发布于 2025-01-02 12:49:27 字数 618 浏览 2 评论 0原文

在表单数据源 (SalesLine) 上,我有一个 validateWrite 方法,该方法依次调用 super() 方法来调用 validateWrite 方法SalesLine 表以及其他检查。

在 SaleLine 表中,我具有用于记录并有时停止数据更改的自定义功能。

我不希望当我从新表单写入 SalesLine 时触发此功能。因此,我想在 SalesLine 表的 validateWrite 方法中检查条件,以查明是否从我的新表单调用了 validateWrite 。如果从我的新表单调用 SalesLine 写入,这将允许我跳过数据更改记录/停止。

正确的做法是什么?

我可以创建一个布尔值 recordSaveChecks 并在调用 SalesLine.write() 之前设置它,但是有更好的方法吗?

编辑:澄清一下,我没有要添加的特定于表单的自定义验证,我有一个系统范围的验证(因此位于 SaleLine 表上),从 1 个特定表单调用时需要跳过该验证。

On a form data source (SalesLine) I have a validateWrite method, which in turn calls the super() method to call the validateWrite method on the SalesLine table, amongst other checks.

In the SaleLine table I have custom functionality for recording, and sometime stopping, data changes.

I don't want this functionality to be triggered when I write to SalesLine from my new form. Therefore I want to check a condition, within the validateWrite method on the SalesLine table, to find out if the validateWrite was called form my new form. This will allow me to skip the data change recording/stopping if the SalesLine write was called from my new form.

What is the correct approach?

I could create a boolean recordSaveChecks and set it before calling SalesLine.write(), but is there a better way?

Edit: To clarify, I do not have form specific custom verification to add, I have a system-wide verification (therefore sits on the SaleLine Table), which needs to be skipped when called from from 1 specific form.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

紫竹語嫣☆ 2025-01-09 12:49:27

最好的选择可能是将特定于表单的自定义移至表单的数据源而不是表本身。但是,如果您确实想向表中添加特定于表单的代码,您可以在 Tables\Address.update() 中查看示例,其中检查 this.dataSource().formRun( ).name() 来确定它是否已从相关表单中调用。

The best option may be to move the customization that is form specific onto the form's data source rather than on the table itself. But if you true want to add form-specific code to the table, you can see an example in Tables\Address.update(), where it checks this.dataSource().formRun().name() to determine if it has been called from the relevant form.

墨落画卷 2025-01-09 12:49:27

您可以将代码放在 ValidateWrite() 方法中的 SalesLine DataSource 上,然后进行超级调用,如下所示:

ret = YourCheckGoesHere;

if(ret)
{
   ret = super();
}
else
{
    info("Why validation failed goes here");
}
   return ret;

You could put your code on the SalesLine DataSource in the ValidateWrite() method, before the super call Something like this:

ret = YourCheckGoesHere;

if(ret)
{
   ret = super();
}
else
{
    info("Why validation failed goes here");
}
   return ret;
迷雾森÷林ヴ 2025-01-09 12:49:27

然后,您将验证逻辑实现到表中,而不是表单中,因为您需要在系统范围内进行验证,但在插入/更新记录时需要阻止此验证。

我认为您可以通过重写 Form DataSource 的 write() 方法并使用 SalesLine.doInsert(); 和 SalesLine.doUpdate();

Then you've implemented the validation logic into Table not into the Form because you need the validation to be system wide but you need to prevent this validation when Insert/Update the record.

I think you can by override write() method of Form DataSource and use SalesLine.doInsert(); and SalesLine.doUpdate();

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文