2016-11-29 60 views
0

我有一個Xpage應用程序使用擴展庫,其中xsp.extlib.convstate對於三個用戶之一爲'null',直到他們手動刷新頁面爲止。所有三個用戶使用Citrix通過RDP訪問應用程序,而所有三個用戶的Internet選項都相同。試圖弄清楚爲什麼會發生這種情況。該應用程序僅在一個9.0.1服務器上。xsp.extlib.convstate返回null

+0

這是他們第一次訪問應用程序嗎?什麼時候它是空的?即你如何訪問它? –

回答

0

從源代碼的外觀,如果有尚未初始化一個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」狀態,說明我不加以防護不要以爲這樣的犯規d在頁面的第一個視圖上運行,因爲沒有任何狀態可以恢復。

    @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); 

這聽起來像你爲什麼看到你的行爲的解釋?

+0

該應用程序使用OneUILayout,因此儘管您的解釋給出了某些原因,但考慮到此行爲僅適用於3個用戶中的一個,因此無法理解。 –

+0

對於第一個用戶是否每個新頁面都發生?或只爲他們加載的第一頁?他們都通過相同的初始url訪問應用程序嗎? –

+0

他們都通過相同的網址進行訪問。由於我們現在已經刪除了調試工具欄,我們不能再看到對話狀態的值。感謝您的回答 –