启用/禁用从代码编辑表单字段
我不是 Notes 程序员,但是,由于我的罪孽,最近一直在为内部项目开发一些 Notes 功能。 我需要根据情况启用/禁用字段编辑。 在我看来,这是一个相当标准的功能,我需要,但我无法在任何地方找到有关如何执行此操作的任何信息。
在表单设置(和其他字段的 onchange
)代码中,如下所示:
if some requirement = true then
textField.enable = true
else
textField.enable = false
end if
我见过其他地方有一种基于某些代码有条件隐藏段落的解决方法,有 2 个段落具有相反的隐藏条件,一个具有可编辑字段,另一个具有计算字段。 但是,我对 Notes 的了解还不够,无法了解这是如何实现的(我可以在其他形式上看到它的实现,但 Notes 中似乎有一些“神奇”的步骤,我要么看不到,要么不明白)。
[编辑] Kerr 的回复似乎就是我正在寻找的内容,但我仍然找不到 InputEnabled 属性所在的位置。 在最初的问题中应该说,我正在使用 Notes 7.0.3。
公平地说,何时启用/禁用该字段的情况并不重要,它只是设置了一些布尔条件,在我的情况下仅在表单加载时,所以我什至不必担心这种动态变化当表单显示时。
我在使用 Notes 时遇到了一些问题,其中最大的问题是它与 Designer UI 的联系如此紧密,这简直是太糟糕了。 我可以用大多数 GUI 语言(C#、Java、Delphi,甚至 VB)以编程方式完成此类操作,但我需要在 Notes 中打开属性框并正确设置它们。
作为可选方法,这是可以的,但是强迫您采用这种方式意味着您只能在 IDE 允许的情况下工作,在这种情况下,IDE 在这里似乎积极地与你作对。 您无法打开多个函数/脚本,您无法在不返回左侧菜单的情况下从一个脚本交换到另一个脚本,您无法轻松地在代码库中搜索变量/字段的出现(相信我,这对我来说是一个重大失败,因为在我的例子中,Notes 或内部代码库似乎大量使用了全局变量!),您只能通过显示的属性框来处理字段,您无法在其中编辑代码设计者同时通过主 Notes 客户端进行调试。
虽然 Java 方面的编码比 LotusScript 好,但它仍然相当糟糕(为什么不能调试 INTO Java 代码?为什么需要为每个 Java 类重新导入 JAR 文件,每个类是否有不同的 CLASSPATH ???)。 可能这在 Notes 8 中得到了改进,我听说它是基于 Eclipse 的。 有谁知道这是真的还是假的?
I'm not a Notes programmer, however, for my sins, have been working on some Notes features for an in-house project recently. I need to enable/disable editing of a field depending on circumstances. It seems to me to be a fairly standard feature, I need, but I can't find any information on how to do this anywhere.
In form setup (and other field's onchange
) code, something like the following:
if some requirement = true then
textField.enable = true
else
textField.enable = false
end if
I've seen other places where there's a workaround of conditionally hiding paragraphs based on some code, having 2 paragraphs with opposite hiding conditions, one with an editable field, the other with a computed field. However, I don't know enough about Notes to see how this is implemented (I can see it done on other forms, but there seem to be some 'magic' steps within Notes which I either can't see or don't get).
[EDIT]
The reply from Kerr seems to be what I'm looking for, but I still can't find out where the InputEnabled property is located. Should have said in the initial question, I'm using Notes 7.0.3.
In fairness, it doesn't matter what the circumstances are for when to enable/disable the field, it's just some boolean condition that is set, in my case only on form loading so I don't even have to worry about this changing dynamically while the form is displayed.
I've got a few issues with Notes, my largest bugbear being that it's so tied so tightly to the Designer UI, which is utter shite. I can do this sort of thing programmatically in most GUI languages (C#, Java, Delphi, even VB), but I need to open property boxes in Notes and set them correctly.
This would be OK as an optional method, but forcing you to go this way means you can only work as well as the IDE lets you in this case, and the IDE here seems to actively work against you. You can't open multiple functions/scripts, you can't swap from one script to another without going back to the menus on the left, you can't easily search the codebase for occurrences of variables/fields (and believe me, this is a major failing for me because either Notes or the internal codebase in my case seems to make a lot of use of global variables!), you can only work with fields through the property boxes that get displayed, you can't edit code in Designer while debugging through the main Notes client.
While the Java side of the coding is better than LotusScript, it's still fairly crappy (why can't you debug INTO Java code?? Why do you need to re-import JAR files for each Java class, does each class have a different CLASSPATH???). Possibly this was improved in Notes 8, I hear it's based on Eclipse. Does anyone know whether this is true or not?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听到有关“情况”的更多细节会有所帮助,但处理此问题的最常见方法是在要启用/禁用的字段上使用隐藏时公式。
从技术上讲,您并没有启用或禁用该字段,只是隐藏它,但通常效果也一样。
由于 Notes 中可使用的事件很少,因此开发人员通常使用文档刷新作为“事件”来导致字段隐藏或显示。
假设您有两个字段,分别称为 TriggerField 和Subject。 还假设您想根据 TriggerField 中的值禁用主题。 最简单的方法是将 TriggerField 设置为对话框列表类型并选中“关键字更改时刷新字段”选项。 这意味着当对话框列表的值发生变化时,整个文档将被刷新。
然后,在主题字段的隐藏时间公式中,指定何时显示或隐藏该字段的条件。 每当字段值发生变化,然后刷新文档(即表单)时,就会隐藏何时重新计算公式。
根据您的具体情况,还有其他方法可以解决此问题。 如果您想让用户自己刷新表单,请在表单上放置一个调用 @Command([ViewRefreshFields]) 命令的按钮。 如果您想同时对表单进行其他更改,则可以在刷新命令之前向该按钮添加任何其他公式。
另一种选择是使某个字段仅显示。 然后创建一个运行 LotusScript 的按钮,以允许用户更改该仅显示字段。 在脚本中,您可以提示用户输入值,设置仅显示字段,然后调用文档刷新。
It would help to hear more specifics about the 'circumstances', but the most common way to handle this is to use a hide when formula on the field you want to enable/disable.
Technically you are not enabling or disabling the field, just hiding it, but usually that works just as well.
Since there are few events to work with in Notes, developers commonly use the document refresh as the 'event' to cause the field to hide or show.
Let's assume you have two fields called TriggerField and Subject. Say also you want to disable the Subject based on a value in the TriggerField. The easiest way to do so is to set the TriggerField as a Dialog List type and check the "Refresh fields on keyword change" option. This means when the value of the dialog list changes, the entire document will get refreshed.
Then in your hide when formula for the Subject field, you specify your criteria for when to show or hide that field. Anytime field values change, followed by a refresh of the document (i.e. form), that hide when formula will be re-evaluated.
There are other ways, depending on your circumstances, to solve this problem. If you want to let the user refresh the form themselves, put a button on the form that calls the @Command([ViewRefreshFields]) command. You can add any other formulas to that button before the refresh command if you want to make other changes to the form at the same time.
Another option is to make a certain field display-only. Then create a button that runs LotusScript to allow users to change that display-only field. In the script you can propmt the user for a value, set the display-only field, and then call for a document refresh.
在 ND7 及更高版本中,如果您只想禁用输入字段,请在要禁用的字段的 InputEnabled 部分中编写适当的公式。
因此,我有两个字段,一个称为“触发器”,一个值为“On”的复选框,另一个主题是文本字段。 当选中“触发器”时,我希望启用“主题”值。
我只是将以下公式放入“主题”字段的“启用输入”元素中:
我还希望每当“触发器”的值发生更改时都重新计算公式,因此我选择“触发器”字段上的“关键字更改时刷新字段”选项。
如果您陷入旧版本,则需要适当隐藏段落。
In ND7 and up if you want to just disable the field for input, write an appropriate formula in the InputEnabled section of the field you want to disable.
So I have two fields one called Trigger, a checkbox with the value "On" and another Subject that is a text field. When Trigger is checked I want the value Subject to be enabled.
I simply put the following formula in the Input Enabled element of the field Subject:
I also want this to be recalculated whenever the value of Trigger changes so I select the "Refresh fields on keyword change" option on the Trigger field.
If you're stuck in an older version you need to to hide paragraphs appropriately.