Powerbuilder:调用accepttext方法是个好主意吗

发布于 2024-09-29 06:33:28 字数 339 浏览 0 评论 0原文

这个问题说明了一切。我想知道手动调用 accepttext()pfc_accepttext 来强制 powerbuilder 接受数据窗口字段中的值是否是个好主意。

这个问题背后的原因是我在弹出窗口中有一个数据窗口,其中包含一些字段。当用户在该字段中输入值并按下OK按钮时,数据窗口将被保存并关闭弹出窗口。单击“确定”按钮后,最后一个字段未正确接受输入值。这就是为什么我考虑手动触发 accepttext()pfc_accepttext 事件。

任何帮助将不胜感激!

谢谢。

The question says it all. I want to know if it a good idea to manually call the accepttext() or pfc_accepttext to force powerbuilder to accept the values in the datawindow fields.

The reason behind this question is that I have a datawindow in a popup window which contains some fields. When the user enters values in that fields and presses an OK button, the datawindow is saved and the popup window is closed. When the ok button is clicked, the last field isn't properly accepting the input value. That's why I was thinking of manually firing accepttext() or pfc_accepttext event.

Any help will be appreciated!!!

Thanks.

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

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

发布评论

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

评论(2

末が日狂欢 2024-10-06 06:33:28

是的,在尝试保存任何数据窗口之前确保触发 dw.accepttext() 是一个非常好的主意。否则,就像您指出的那样,它可能不会保存用户输入的所有信息,除非他们从每个字段中跳出;最终用户不应该这样做。

对于更复杂的窗口/对象,您可以为此创建一个简单的函数,例如 wf_accepttext() ,其中包含每个需要的数据窗口的所有 dw.accepttext() 调用有待更新。然后您可以在尝试更新数据窗口之前调用该函数。

(编辑)其他想法:

特里的上述评论让我想起了我在最初的答案中忽略的一些内容。如果字段验证失败,accepttext() 将返回 -1
因此,如果您创建一个自定义函数来处理所有 accepttext() 调用,请确保编写它来处理此返回代码。像这样的东西应该足够了:

/* wf_accepttext() */
if dw_foo.accepttext() = -1 then return false
if dw_bar.accepttext() = -1 then return false
// etc..
return true

这样,在保存函数的顶部,我们将其称为 wf_save(),您可以这样做:

/* wf_save() */
if not wf_accepttext() then return false
/* any other save validation and the dw.update() goes below here */

如果某些内容未验证,< code>wf_save() 将退出,并且您的 itemchanged 事件应该有代码来处理其余的事情。

Yes, it is a very good idea to make sure a dw.accepttext() is fired prior to attempting to save any datawindow. Otherwise, like you pointed out, it may not save all the information the user enters unless they tab out of each field; which end users should not be expected to do.

For more complicated windows/objects you could create a simple function for this, such as wf_accepttext() which contains all the dw.accepttext() calls for each datawindow that will need to be updated. Then you can just call that function before you attempt to update your datawindows.

(Edit) Additional thoughts:

Terry's comment above reminded me of something I neglected to include in my initial answer. accepttext() returns -1 if a field's validation fails.
So if you make a custom function to handle all your accepttext() calls, make sure you write it to handle this return code. Something such as this should be sufficient:

/* wf_accepttext() */
if dw_foo.accepttext() = -1 then return false
if dw_bar.accepttext() = -1 then return false
// etc..
return true

This way, at the top of your save function, let's call it wf_save(), you can do this:

/* wf_save() */
if not wf_accepttext() then return false
/* any other save validation and the dw.update() goes below here */

And in the event that something doesn't validate, wf_save() will bail, and your itemchanged event should have code to handle the rest.

你的他你的她 2024-10-06 06:33:28

因此,在没有看到您的代码的情况下,并不完全清楚为什么 pfc_AcceptText 没有触发。然而,我可以说的是 pfc_AcceptText 是由 PowerBuilder 基础类 (PFC) 逻辑工作单元服务定义的事件。虽然您通常想要或需要了解的有关 PFC LUW 服务的更多内容可以在 我的文章,您让我意识到我忘记记录此服务的预期入口点。其意图(正如您应该能够在 (pfcmain.pbl)pfc_w_master [closequery] 中看到的那样)是您触发窗口的 pfc_Save 事件,该事件将以适当的顺序触发所有 LUW 事件(例如 pfc_Validation、pfc_PreUpdate)。

祝你好运,

特里。

So, without seeing your code, it's not entirely clear why pfc_AcceptText isn't firing. However, what I can say is that pfc_AcceptText is an event defined by PowerBuilder Foundation Class's (PFC's) Logical Unit of Work service. While more than you'd generally ever want or need to know about PFC's LUW service can be found in my article, you've made me realize I've forgotten to document the intended entry point to this service. The intention (as you should be able to see in (pfcmain.pbl)pfc_w_master [closequery]) is that you fire the window's pfc_Save event, which will fire all the LUW events (e.g. pfc_Validation, pfc_PreUpdate) in the appropriate sequence.

Good luck,

Terry.

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