2015-09-25 67 views
1

我正在構建一個應用程序,其中有一個mainDoc可以有一個或多個相關的註釋文檔。在mainDoc中有一個綁定到Payments.getAllItems(WFSMainDoc.getValue("LinkKey"));的重複控件。java類Payments具有操作PaymentItems的ArrayList的方法。 getAllItems方法捕獲所有相關的NotesDocuments並將它們加載到ArrayList中。如果ArrayList已經存在,它只會返回先前構建的ArrayList。在重複按鍵設置viewScope.vsRIndex = rIndex;viewScope.vsShowPayment = true;現在顯示的panelPaymentDetail並具有java.lang.Object類型的自定義屬性,並使用pItem = Payments.getItem(rIndex); return pItem;在自定義控件上的compositeData中定義一個對象屬性

以上所有作品加載pItem自定義控件和我有幾個樣本下面的控件。我有兩個問題: 1. compositeData.pItem一遍又一遍地計算,並且據我所知,即使我正在付款輸入「表單」中編輯它們,我仍然會從Payments.getAllItems()始終返回原始值 - 然後問題我如何阻止這種重複計算?

  1. 支付輸入自定義控件中的保存按鈕不會觸發(點擊時不會出現任何打印語句)我認爲Object pItem的重新加載會受到阻礙。

測試主文檔控制:

<?xml version="1.0" encoding="UTF-8"?> 
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" 
xmlns:xc="http://www.ibm.com/xsp/custom"> 
    <xp:this.data> 
     <xp:dominoDocument var="WFSMainDoc" formName="frmMainDoc" 
      computeWithForm="onsave" ignoreRequestParams="false"> 
      <xp:this.documentId><![CDATA[${javascript:var UNID:String = sessionScope.get("ssUNID"); 
(UNID == null || UNID == "") ? "" : UNID}]]></xp:this.documentId> 
      <xp:this.action><![CDATA[${javascript:if (sessionScope.containsKey("ssUNID")){ 
    if(sessionScope.get('ssUNID').length){ 
     sessionScope.get('ssAction') == 'edit' ? 'editDocument':'openDocument' 
    } else { 
     return 'createDocument' 
     break; 
    } 
}else{ 
    return "createDocument"; 
    break; 
}}]]></xp:this.action> 
      <xp:this.databaseName><![CDATA[${appProps[sessionScope.ssApplication].appFilePath}]]></xp:this.databaseName> 
     </xp:dominoDocument> 
    </xp:this.data> 

    Main document 
    <xp:br></xp:br> 

    <xp:inputText id="inputText1" value="#{WFSMainDoc.LinkKey}" 
     defaultValue="#{javascript:@Unique}"> 
    </xp:inputText> 

    <xp:br></xp:br> 
    Other Fields and controls 
    <xp:br></xp:br> 
    <xp:panel id="panelPaymentContainer"> 
     <xp:repeat id="repeatData" rows="10" var="pItem" 
      indexVar="rIndex"> 
      <xp:this.value><![CDATA[#{javascript:Payments.getAllItems(WFSMainDoc.getValue("LinkKey"));}]]></xp:this.value> 
      <xp:button id="buttonEditPayment" 
       rendered="#{javascript:(WFSMainDoc.isEditable())}"> 
       <xp:eventHandler event="onclick" submit="true" 
        refreshMode="partial" refreshId="panelPaymentsContainer"> 
        <xp:this.action><![CDATA[#{javascript:try{ 
viewScope.vsRIndex = rIndex; 
viewScope.vsShowPayment = true; 
break; 
}catch(e){ 
    WFSUtils.sysOut("Error in calling dialogPayment " + e.tostring) 
}}]]> 
        </xp:this.action> 
       </xp:eventHandler> 
      </xp:button> 
      <br /> 

     </xp:repeat> 
     <xp:panel id="panelPaymentInput"> 
      <xp:this.styleClass><![CDATA[#{javascript:(viewScope.vsShowPayment) ? "" : "display=none";}]]></xp:this.styleClass> 


      <xc:ccTestPaymentInput rendered="#{javascript:(viewScope.vsShowPayment)}"> 
       <xc:this.pItem><![CDATA[#{javascript:try{ 
     var debug:Boolean = true; 
     if (debug) WFSUtils.sysOut("Open existing row = " + viewScope.vsRIndex) 
     rIndex = parseInt(viewScope.vsRIndex.toString()); 
     if (debug) WFSUtils.sysOut("rIndex = " + rIndex); 
     pItem = Payments.getItem(rIndex); 
     return pItem; 

}catch(e){ 
    WFSUtils.sysOut("Failure in Custom Prop of add item " + e.toString()); 
    return null; 
}}]]></xc:this.pItem> 
      </xc:ccTestPaymentInput> 
     </xp:panel> 
    </xp:panel><!-- panelPaymentContainer --> 
    <xp:br></xp:br> 
    <xp:br></xp:br> 
</xp:view> 

支付輸入控制

<?xml version="1.0" encoding="UTF-8"?> 
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"> 

    <xp:br></xp:br> 

    Actual Pay Date:&#160; 
    <xp:inputText id="actualPayDate" 
     value="#{compositeData.pItem.actualPayDate}"> 
     <xp:dateTimeHelper id="dateTimeHelper1"></xp:dateTimeHelper> 
     <xp:this.converter> 
      <xp:convertDateTime type="date"></xp:convertDateTime> 
     </xp:this.converter> 
    </xp:inputText> 
    <br /> <br /> 
    <xp:button value="Save" id="button1"> 
          <xp:eventHandler event="onclick" 
           submit="true" refreshMode="partial" refreshId="panelPayments"> 
           <xp:this.action><![CDATA[#{javascript:try{ 

var debug:Boolean = true; 
if (debug) print("Start Payment save"); 
var pos:Integer = parseInt(viewScope.vsRIndex.toString()); 
if (debug) print("Working with pos = " + pos + " Call saveThisItem"); 

if (Payments.saveThisItem(compositeData.pItem , pos)){ 
    if (debug) print("save Payments Worked "); 
}else{ 
    if (debug) print("save Payments FAILED "); 
} 

}catch(e){ 
    print("payment save Error " + e.tostring); 

}finally{ 
    viewScope.vsExpPayDate = ""; 
    viewScope.remove("vsShowPayment"); 
    viewScope.remove("vsRIndex"); 
    viewScope.remove("vsGotItem") 
}}]]></xp:this.action> 
          </xp:eventHandler> 
    </xp:button> 


</xp:view> 

回答

0

這是非常複雜的,我從認識你想在這裏實現什麼很遠。但至少我在代碼中發現了一些奇怪的現象:

ad 1:有一個面板id =「panelPaymentContainer」包含重複。在這個重複是一個按鈕做一個ID =「panelPayment s s」部分刷新一個按鈕「這是一個錯字(複數與單數形式的」支付(s))?該按鈕應刷新面板? 假設這個假設是正確的:每次你點擊按鈕時,面板會與其所有內容一起刷新,因此也刷新了重複的數據源,所以pItem將始終從「外部輸入」推入重複內容中。 refreshId的東西不是拼寫錯誤,那麼它應該是什麼?我努力閱讀整個代碼,但有很多,所以我可能錯過了一些東西

ad 2:類似的東西在這裏:保存按鈕嘗試使用id =「panelPayments」刷新某些內容,但我無法看到任何與此ID相關的內容。因此,難怪它似乎沒有做到任何有用的。

我對這些複雜任務的建議是:儘量將所有東西都剝離到最基本的要領;你的代碼越複雜,就越難找到它的錯誤。從一個面板開始,重複和一些簡單的控件,如按鈕和一堆計算字段來顯示一些測試值。然後只要這個非常簡單的模型正在工作,您就可以開始添加它。 - 簡化也可以幫助別人發現你的概念錯誤,順便說一句。

+0

這些重新拼寫錯誤,因爲我試圖使它更簡單:-)我今天晚些時候將重新編輯和擴大描述 –

+0

Lothar - 感謝您的意見。我要重寫我的問題。我已經縮小了它的範圍,它與在付款輸入控制中返回pItem的自定義屬性有關。 –