在自定义控件上的compositeData中定义一个对象属性

问题描述:

我正在构建一个应用程序,其中有一个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> 

这是非常复杂的,我从认识你想在这里实现什么很远。但至少我在代码中发现了一些奇怪的现象:

ad 1:有一个面板id =“panelPaymentContainer”包含重复。在这个重复是一个按钮做一个ID =“panelPayment s s”部分刷新一个按钮“这是一个错字(复数与单数形式的”支付(s))?该按钮应刷新面板? 假设这个假设是正确的:每次你点击按钮时,面板会与其所有内容一起刷新,因此也刷新了重复的数据源,所以pItem将始终从“外部输入”推入重复内容中。 refreshId的东西不是拼写错误,那么它应该是什么?我努力阅读整个代码,但有很多,所以我可能错过了一些东西

ad 2:类似的东西在这里:保存按钮尝试使用id =“panelPayments”刷新某些内容,但我无法看到任何与此ID相关的内容。因此,难怪它似乎没有做到任何有用的。

我对这些复杂任务的建议是:尽量将所有东西都剥离到最基本的要领;你的代码越复杂,就越难找到它的错误。从一个面板开始,重复和一些简单的控件,如按钮和一堆计算字段来显示一些测试值。然后只要这个非常简单的模型正在工作,您就可以开始添加它。 - 简化也可以帮助别人发现你的概念错误,顺便说一句。

+0

这些重新拼写错误,因为我试图使它更简单:-)我今天晚些时候将重新编辑和扩大描述 –

+0

Lothar - 感谢您的意见。我要重写我的问题。我已经缩小了它的范围,它与在付款输入控制中返回pItem的自定义属性有关。 –