Search code examples
xpageslotus-noteslotus-dominolotus

Repeat Control inside repeat control in XPages


I have a repeat control inside another repeat control. The concept is to create something like a calendar. So i want to create a 2 dimension repeat and i used one repeat to create "rows" vertically and inside it another one to create columns horizontally. The second repeat control has an input text control inside a div control. The code is below:

    <xp:repeat id="repeat4" rows="30">
        <xp:this.value>
<![CDATA[#{javascript:var projects2 = new Array("Project 1","Project 2");
    return projects2;}]]>
</xp:this.value>
<xp:repeat id="repeat3" rows="31">
<xp:this.value><![CDATA[#{javascript:var inBoxes = new java.util.Vector();
    for(i=1;i<=5;i++){
        inBoxes.add(i);
    }

    return inBoxes;}]]>
</xp:this.value>
    <xp:div id="DivInputs" styleClass="DivInputs">
  <xp:inputText id="inputText1"
 style="width:100%">
 </xp:inputText>
    </xp:div>
    </xp:repeat>
   </xp:repeat>

I want now to get the value of an input field so if i use this it works:

repeat4.setRowIndex(0); 
repeat3.setRowIndex(0); 
sum = sum + inputText1.getValueAsString();

But when i do this loop it only gets only the first row cell value:

for(i=0;i<2;i++){
repeat4.setRowIndex(i);
repeat3.setRowIndex(0);
sum = sum + inputText1.getValueAsString();
}

Any ideas?


Solution

  • You need to change your approach. Going after values should be done using bindings, not getValue. So do something like

      var x = [[0,0,0,0,0,0,0],[...],....];
      viewScope.calendar = x;
    

    Then bind the controls to the variable. This removes the need to check for the exact position or variable name.