xsp.extlib.convstate returns 空

xsp.extlib.convstate returns null

我有一个使用扩展库的 Xpage 应用程序,其中三个用户之一的 xsp.extlib.convstate 是 'null',直到他们手动刷新页面。所有三个用户都使用 Citrix 通过 RDP 访问应用程序,并且 Internet 选项对于所有三个用户都是相同的。试图弄清楚为什么会发生这种情况。该应用程序仅在一台 9.0.1 服务器上。

从源码来看,如果conversationState还没有初始化,conversationState不会被初始化,直到:

  1. Render Response 阶段之后(在阶段监听器中:com.ibm.xsp.extlib.component.layout.impl.ApplicationPhaseListener)

    @SuppressWarnings("unchecked") // $NON-NLS-1$
    public void afterPhase(PhaseEvent event) {
        if(event.getPhaseId()==PhaseId.RENDER_RESPONSE) {
            // After the render phase, we save the conversion state
            ConversationState.saveInSession(event.getFacesContext());
        }
    }
    
  2. 在 UIApplicationLayout 的 setParent 方法中,这似乎受到 'isRestoringState' 条件的保护,这意味着我认为这不会 运行 首先页面视图,因为没有任何状态可恢复。

    @Override
    public void setParent(UIComponent parent) {
        super.setParent(parent);
        if( null == parent ){ // removing parent
           return;
        }
    
        // TODO should move this initialization to initBeforeContents instead
        FacesContextEx context = (FacesContextEx) getFacesContext();
        if(null != context && !context.isRestoringState()) {
            ConversationState cs = ConversationState.get(context, FacesUtil.getViewRoot(this), true);
    
            // Initialize the conversation state
            // Set the current navigation path to the UserBean
            ApplicationConfiguration conf = findConfiguration();
            if(conf!=null) {
                String navPath = conf.getNavigationPath();
                if(StringUtil.isEmpty(navPath)) {
                    // If there isn't a navigation path that is defined, the use the default one
                    if(StringUtil.isEmpty(cs.getNavigationPath())) {
                        navPath = conf.getDefaultNavigationPath();
                    }
                }
                if(StringUtil.isNotEmpty(navPath)) {
                    cs.setNavigationPath(navPath);
                }
            }
        }
    }
    

所以这可能解释了为什么它直到第 2 个页面视图才被初始化。 您可以尝试在尝试使用 ConversationState 之前强制初始化它,也许是在 beforePageLoad 中,通过调用 com.ibm.xsp.extlib.component.layout.ConversationState 的 get() 方法之一。 请注意,布尔参数告诉方法在 ConversationState 不存在时创建它。 我在 ServerSide Javascript 上做的不多,但我想这行得通吗?情绪是正确的。

#{javascript: com.ibm.xsp.extlib.component.layout.ConversationState.get(facesContext, true); }

如果您在 java 中这样做,那么:

ConversationState.get(FacesContext.getInstance(), true);

这听起来像是在解释为什么您会看到自己的行为吗?