java - defining an object property in a compositeData on a custom control -


i'm building application have maindoc can have 1 or more related notes documents. in maindoc there repeat control bound payments.getallitems(wfsmaindoc.getvalue("linkkey")); java class payments has methods manipulate , arraylist of paymentitems. getallitems method grabs of related notesdocuments , loads them arraylist. if arraylist exists returns built arraylist. button in repeat sets viewscope.vsrindex = rindex; , viewscope.vsshowpayment = true; displays panelpaymentdetail , custom control has custom property of type java.lang.object , load pitem using pitem = payments.getitem(rindex); return pitem;

all of above works , have couple sample controls below. have 2 issues: 1. compositedata.pitem computed on , on again , far can tell keeps returning original values payments.getallitems() though i'm editing them in payment input 'form' -- question how can block repeated calculation?

  1. the save button in payment input custom control not appear fire (none of print statements occur when clicked) think reloading of object pitem gets in 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 , 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 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> 

this complicated, , i'm far understanding you're trying achieve here. @ least found few oddities in code:

ad 1: there panel id="panelpaymentcontainer" containing repeat. inside repeat button doing partialrefresh on id="panelpaymentscontainer" >> typo (plural vs. singular forms in "payment(s))? should button refreshing panel? assuming assumption true: every time click button panel refreshed contents, refreshing repeat's datasource. , pitem pushed "outside in" content of repeat. - if refreshid thing not typo, should be? tried hard read entire code, there's lot of it, might have missed something

ad 2: similar thing here: save button tries refresh id="panelpayments", cannot see id. no wonder doesn't appear useful.

my recommendation complicated tasks these: try strip down bare essentials; more complicated code harder find mistakes. start panel, repeat , few simple controls button , bunch of computed fields display test values. simple model working can start add it. - simplifying helps others find mistakes in concept, btw.


Comments