Xpages 文档更改文档模式? [英] Xpages document changing document mode?

查看:17
本文介绍了Xpages 文档更改文档模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发生了一件奇怪的事情;像往常一样,不幸的是,我无法发布代码,因此我正在描述问题,以防万一有人可以提出可能的原因.

I have a strange thing occurring; as usual, I can't post code, unfortunately, so I'm describing the problem in case anyone can suggest a possible cause.

我有一个包含自定义控件的 xpage;自定义控件通过链接处理文档锁定和更改为编辑/只读模式.文档锁定是通过设置基于 UNID 的 applicationScope 变量来完成的.为了让系统上的其他用户更友好,我定期在页面上运行一个功能来检查文档是否被锁定并适当更新链接/标签/工具提示(例如,如果被其他用户锁定,则编辑" 按钮被禁用;当锁定被释放时,它被重新启用).这是通过标准的、简单的基于 dojo 的 ajax 调用调用xagent"来完成的.

I have an xpage with a custom control included on it; the custom control handles document locking and changing to edit/read-only modes via links. The document locking is done by setting an applicationScope variable based on the UNID. To make it more friendly for other users on the system, I run a function periodically on the page to check whether the document is locked or not and update a link/label/tooltips appropriately (e.g. if locked by another user, then the "Edit" button is disabled; when the lock is released, it's re-enabled). This is done by calling an "xagent" through a standard, simple dojo-based ajax call.

出于某种原因,系统的行为会在 45 秒到一分钟后变得不稳定.我每十秒左右检查一次锁定状态,所以第一次调用时不会发生这种情况.我正在显示与文档相关的记录列表;每条记录都是重复中的一行.当我第一次进入编辑模式时,所有控件都按原样显示,即可编辑.如果用户使用组合框更改特定值,则会使用部分刷新来更新整行.当事情变得不稳定时,我注意到该行开始以只读模式刷新,这表明文档正在更改编辑模式.我故意更改编辑模式的唯一时间是按下取消"或保存"按钮.(锁定机制本身与编辑模式没有任何关系.)

For some reason, the behavior of the system gets erratic after 45 seconds to a minute. I'm checking the lock status every ten seconds or so, so it's not happening with the first call. I'm displaying a list of records associated with the document; each record is a row in a repeat. When I first go into edit mode, the controls are all displayed as they should be, i.e. editable. If the user changes a particular value with a combobox, it updates the whole row with a partial refresh. When things get erratic, I noticed that the row starts refreshing in read-only mode, which suggests to me that the document is changing edit mode. The only time I knowingly change edit mode is if a "Cancel" or "Save" button is pressed. (The locking mechanism itself doesn't have anything to do with the edit mode.)

我正在做的 ajax 调用似乎是这个问题的根源.但是我已经将 xagent 和客户端代码剥离到几乎没有任何内容,而且它仍在发生.我看不出是什么导致了这种行为.任何人都可以冒险猜测吗?谢谢....

It certainly seems like the ajax call I'm making is at the root of this. But I've stripped the xagent and the client-side code down to practically nothing, and it's still happening. I can't see what would be causing this behavior. Can anyone hazard a guess? Thanks....

推荐答案

也许检查服务器日志文件是否有如下警告:

Maybe check if the server log file has warnings like:

警告 CLFAD####W:状态数据不可用于/page,因为在缓存中未找到控制树.

WARNING CLFAD####W: State data not available for /page because no control tree was found in the cache.

如果您看到这些警告,则可能是服务器无法再在缓存中找到当前的 XPage 页面实例.在这种情况下,页面将恢复到初始状态,就像第一次打开页面时一样.这可能就是文档进入只读模式的原因.

If you're seeing those warnings, it could be that the server can no longer find the current XPage page instance in the cache. In that case the page will revert to the initial state, like when the page was first opened. That might be why the document goes to read-only mode.

服务器端页面实例的会话缓存在xsp.persistence.mode=basic时只保存4页,或者在xsp.persistence.mode=file或fileex时保存16个实例.

The session cache of server-side page instances only holds 4 pages when xsp.persistence.mode=basic, or it holds 16 instances when xsp.persistence.mode=file or fileex.

如果您加载 4 个 xagent 页面实例,那么这将填满缓存,并且将无法再找到您正在查看的当前 XPage 的页面实例.因此 XPage 将停止执行服务器端操作,部分刷新将始终显示页面该区域的初始状态.

If you load 4 xagent page instances, then that will fill the cache, and it will no longer be able to find the page instance for the current XPage you are viewing. So the XPage will stop performing server-side actions, and partial refresh will always show the initial state of that area of the page.

为了避免这个问题,在 xagent 页面中,您可以在 xp:view 标签上设置 viewState="nostate",这样就不会为 xagent 页面保存页面实例,如下所述:https://tobysamples.wordpress.com/2014/12/11/无状态无问题/

To avoid that problem, in the xagent page you can set viewState="nostate" on the xp:view tag, so that page instances are not saved for the xagent page, as described here: https://tobysamples.wordpress.com/2014/12/11/no-state-no-problem/

或者你可以为 xagent 创建和重用一个页面实例,所以只创建一个.也就是说,在第一次调用 XAgent 时,让 xagent 返回 xagent 页面实例的 $$viewid 值(#{javascript:view.getUniqueViewId()}),然后在对 xagent 的后续请求中使用该 $$viewid 在请求中,恢复现有的 xagent 页面实例,而不是创建将填充缓存的新实例.所以后续的 xagent 请求会是这样:

Or else you can create and reuse one page instance for the xagent, so only one is created. That is, on the first call to the XAgent, have the xagent return the $$viewid value for the xagent page instance (#{javascript:view.getUniqueViewId()}), and then in subsequent requests to the xagent use that $$viewid in the request, to restore the existing xagent page instance instead of creating new instances that will fill the cache. So the subsequent xagent requests will be like so:

/myApp.nsf/xagent1.xsp?$$viewid=!aaaaaaaa!

/myApp.nsf/xagent1.xsp?$$viewid=!aaaaaaaa!

这篇关于Xpages 文档更改文档模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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