显示包含大量字段的组时 Orbeon 页面渲染速度缓慢

发布于 2024-12-03 20:00:18 字数 524 浏览 0 评论 0原文

我正在处理 Orbeon 表单,并且有一个与性能相关的问题,如下所述。

我有一个表格,最初有五个字段。在第五个下拉字段中,如果我选择“是”,由于 xforms:group 它会显示一个字段块(该块大约有 40 个字段)。 由于该块位于重复部分,因此我可以添加/删除尽可能多的块。

现在,如果我添加 10 个块,并且当我将第五个下拉字段从任意值切换为“是”时,则需要 2 秒多的时间才能显示所有块。

我在具有 2GB RAM 的 Windows XP 桌面上使用 Orbeon Forms 3.8 和 Tomcat 6。

请让我知道选择“是”时会发生什么(意味着 xforms:group 为 true 时的条件显示),这会花费更多时间来显示。

<xforms:group ref=".[instance('form-attributes')/flag='yes']" >
    //code for the controls here
</xforms:group>

I am working on Orbeon forms and i have a performance related issue as explained below.

I have a form where I have five fields initially. On the fifth dropdown field, if I select "Yes", because of xforms:group it shows a block of fields (the block has around 40 fields).
Since the block is in the repeated section, I can add/delete as many blocks as I can.

Now, if I add say 10 blocks and when I toggle the fifth dropdown field from any value to "Yes", it takes more than 2 seconds to display all the blocks.

I am using Orbeon Forms 3.8 and Tomcat 6 on Windows XP desktop with 2GB RAM.

Please let me know what happens when "Yes" is selected (meaning conditional display when xforms:group is true) which is taking more time to display.

<xforms:group ref=".[instance('form-attributes')/flag='yes']" >
    //code for the controls here
</xforms:group>

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

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

发布评论

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

评论(2

独孤求败 2024-12-10 20:00:18

如果您使用的代码如下所示:

<xforms:group ref=".[condition]">
    <!-- Large number of fields -->
</xforms:group>
  1. condition 为 false 时,组内的字段不相关。 XForms 引擎不会计算它们的值、只读状态、有效性、标签、提示、帮助、警报等。
  2. condition 变为 true 时,组的内容变得相关,并且 XForms引擎评估组内的所有控件。
  3. 浏览器需要将所有这些更改应用到 DOM。

通常,步骤 #2 比步骤 #3 快得多,特别是对于 IE7。为了避免步骤 #3 中的大量更新,编写此代码的另一种方法是:

<xhtml:div class="{if (condition) then '' else 'xforms-disabled'}">
    <!-- Large number of fields -->
</xhtml:div>

这样,div 内的字段将始终相关:

  • 好处是当condition 变为 true 时,浏览器可能需要做的就是翻转 div 上的该类。它不一定需要更新内部的所有控件,除非它们的值也发生了变化。
  • 缺点是,当 condition 为 false 时,服务器上的 XForms 引擎需要使 div 内的所有控件保持最新。

但通常情况下,尤其是当您看到 IE7 速度缓慢时,您在客户端上获得的性能远远超过了服务器上可能需要的增加的处理量。

If you are using code that looks like:

<xforms:group ref=".[condition]">
    <!-- Large number of fields -->
</xforms:group>
  1. When condition is false, the fields inside the group are non-relevant. The XForms engine doesn't compute their value, read-only status, validity, label, hint, help, alert, etc.
  2. When condition becomes true, the content of the group become relevant, and the XForms engine evaluates all the controls inside the group.
  3. The browser needs to apply all those changes to the DOM.

Typically, step #2 is much faster than #3, especially with IE7. To avoid the numerous updates on step #3, another way to write this code is:

<xhtml:div class="{if (condition) then '' else 'xforms-disabled'}">
    <!-- Large number of fields -->
</xhtml:div>

With this, the fields inside the div will always be relevant:

  • The upside is that when condition becomes true, all the browser might need to do is to flip that class on the div. It won't necessarily need to update all the controls inside, unless of course their value has also changed.
  • The downside is that while condition is false, the XForms engine, on the server, needs to keep all the controls inside the div up-to-date.

But more often than not, especially when you're seeing IE7 slowness, the performance you gain on the client far outweighs the increased processing that might be needed on the server.

心的憧憬 2024-12-10 20:00:18

我发现这个 链接似乎建议使用span标签而不是div标签,尽管原始的帖子是关于代码崩溃的,当我在 IE 中测试它时,建议的解决方法在我的表单中提供了小的性能改进。希望这段代码能给您带来一些好处。

I found this link that seems to suggest span tag instead of div tag, though the original post was for Code crash, the suggested work around gave a small performance improvement in my form when I tested it in IE. Hope this code will give you some benefit.

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