ToolTip Performance in XPages

2019-09-16 17:54发布

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.

2条回答
聊天终结者
2楼-- · 2019-09-16 18:18

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.

Makes sense?

查看更多
乱世女痞
3楼-- · 2019-09-16 18:44

You can use view.isRenderingPhase() to minimise the lookups during a partial refresh. With the tooltip you can also change the showDelay property so the tooltip has a delay before showing. This is a good thing to do for a view, so it doesn't try to load each tooltip as the mouse moves down the page. dynamicContent="true" may also mean it's not loaded with the page, but only when called - I haven't checked this so I'm not certain.

查看更多
登录 后发表回答