1

I'm building an application where I have mainDoc which can have one or more related notes Documents. In the mainDoc there is a repeat control that is bound to Payments.getAllItems(WFSMainDoc.getValue("LinkKey")); The java class Payments has methods that manipulate and ArrayList of PaymentItems. The getAllItems method grabs all of the related NotesDocuments and loads them into an ArrayList. If the ArrayList already exists it just returns the previously built ArrayList. The button in the Repeat sets viewScope.vsRIndex = rIndex; and viewScope.vsShowPayment = true; which now displays the panelPaymentDetail and the custom control that has a custom property of type java.lang.Object and load pItem using pItem = Payments.getItem(rIndex); return pItem;

all of the above works and I have a couple sample controls below. I have two issues: 1. The compositeData.pItem is computed over and over again and as far as I can tell keeps returning the original values from the Payments.getAllItems() even though I'm editing them in the payment input 'form' -- the question then is how can I block this repeated calculation?

  1. The save button in the Payment Input custom control does not appear to fire (none of the print statements occur when clicked) I think the reloading of the Object pItem gets in the way.

Test Main Document Control:

<?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>

payment Input Control

<?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>
Bill F
  • 2,057
  • 3
  • 18
  • 39

1 Answers1

0

This is all very complicated, and I'm far from understanding what you're trying to achieve here. But at least I found a few oddities in your code:

ad 1: there is a panel with id="panelPaymentContainer" containing a repeat. Inside that repeat is a button doing a partialRefresh on an id="panelPaymentsContainer" >> is this a typo (plural vs. singular forms in "Payment(s))? Should the button be refreshing the panel? Assuming that this assumption is true: every time you click the button the panel is refreshed together with all its contents, thus also refreshing the repeat's datasource. And so pItem will always be pushed from "outside in" into the content of your repeat. - If the refreshId thing is NOT a typo, then what should it be? I tried hard to read the entire code, but there's a lot of it, so I might have missed something

ad 2: similar thing here: the save button tries to refresh something with an id="panelPayments", but I cannot see anything with this id. So no wonder it doesn't appear to do anything useful.

My recommendation for complicated tasks like these: try to strip everything down to the bare essentials; the more complicated your code is the harder it is to find its mistakes. Start with a panel, a repeat and a few simple controls like a button and a bunch of computed fields to display some test values. Then as soon as this very simple model is working you can start to add to it. - Simplifying also helps others to find mistakes in you concept, btw.

Lothar Mueller
  • 2,528
  • 1
  • 16
  • 29
  • Those re typos as I tried to make it simpler :-) I'm going to re-edit and expand the description later today – Bill F Sep 26 '15 at 15:50
  • Lothar - thanks for your input. I'm going to recast my question. I have narrowed it down somewhat and it has to do with the Custom Property that returns pItem in the Payment Input Control. – Bill F Sep 26 '15 at 17:25