XPage 中的工具提示性能 [英] ToolTip Performance in XPages

查看:34
本文介绍了XPage 中的工具提示性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含大约 170 个字段的大型 XPage.我有相当多的领域的工具提示.工具提示查找帮助数据库并返回相关文本.它们工作正常,但由于执行查找的次数太多,它们显着减慢了加载过程.我在加载文本的 JS 中放置了一个 dBar.info 语句,在一次加载文档并将其置于编辑模式时,它似乎已经触发了 6 次工具提示查找.如果它对每个工具提示都这样做,那么显然这就是 XPage 性能缓慢的原因.我在将 DynamicContent 设置为 true 和 false 的情况下都这样做了,结果相似.我很想只删除工具提示,但这违背了目的.有没有办法限制工具提示只在调用时触发查找?就像链接到 MouseOver 事件的东西.在我看来,如果只有几个字段需要内联帮助但不能很好地扩展,则扩展库中的工具提示可以正常工作.就像测试一样,我从 XPage 中删除了所有工具提示,虽然加载速度很慢,但它可能是可以接受的,但工具提示将其慢到了不可接受的程度.

I have a large XPage with about 170 fields on it. I have tooltips for a fair number of the fields. The tooltip does a lookup into a help DB and returns the related text. They work fine but they significantly slow down the load process because of the number of times the lookup is performed. I put a dBar.info statement in the JS that loads the text and in one load the document and put it into edit mode it would appear to have fired that one tooltip lookup 6 times. If it does that for every one of the tooltips then clearly that is the reason for the slow performance of the XPage. I did it both with the DynamicContent set to both true and false with similar results. I'm tempted to just remove the tool tips but that kind of defeats the purpose. Is there a way to limit the tooltip to only fire the lookup when called? Like something linked to the MouseOver event. It seems to me the tooltip in the extension Library works OK if there are only a few fields requiring inline help but does not scale well. Just as a test I removed all the tooltips from the XPage and while the loading is slow it is probably acceptable, but the tooltips slow it to the point of unacceptability.

推荐答案

Bill,这是 ApplicationScope bean 的一个很好的用例.创建一个实现 Map 并使用内部 HashMap 作为缓存的 bean.我们称之为工具提示.在您的工具提示中,您将标签定义为 EL,例如工具提示['经理'].XPage 将调用 get 函数.在其中检查内部 HashMap 是否有值,否则查找它.所以查找只发生一次.

Bill, This is an excellent use case for an ApplicationScope bean. Create a bean that implements Map and uses an internal HashMap as cache. Let's call it tooltip. In your tooltip you define the label as EL e.g. tooltip['Manager']. XPages will call the get function. In it you check the internal HashMap if you have the value, otherwise you look it up. So lookup happens once only.

您可以在初始化时选择加载而不是按需查找.使用应该非常快的视图导航器.因为它将是一个仅加载一次的应用程序范围.

You could instead of looking up on demand opt for loading when initialized. Using a view navigator that should be very fast. Since it would be an Application scope only loaded once.

有意义吗?

这篇关于XPage 中的工具提示性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆