VladP VladP - 3 months ago 18
Javascript Question

xPages nested repeat control doesn't show anything

Here is my xPage with two repeat controls (the second one is nested)

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.beforePageLoad><![CDATA[#{javascript:viewScope.MY_SCOPE = new Array();
viewScope.MY_SCOPE.push(["A1", "B1", ["aaa1", "bbb1", "ccc1"]]);
viewScope.MY_SCOPE.push(["A2", "B2", ["aaa2", "bbb2", "ccc2"]]);
viewScope.MY_SCOPE.push(["A3", "B3", ["aaa3", "bbb3", "ccc3"]]);}]]></xp:this.beforePageLoad>
<xp:repeat id="repeat1" rows="30"
value="#{javascript:viewScope.MY_SCOPE}" var="rowData" indexVar="rowDataIndex"
repeatControls="true">
<xp:text escape="false" id="computedField1">
<xp:this.value><![CDATA[#{javascript:rowData[0]}]]></xp:this.value>
</xp:text>
<xp:repeat id="repeat2" rows="30" var="rowDataSub" indexVar="rowDataSubIndex"
repeatControls="true">
<xp:this.value><![CDATA[#{javascript:rowData[2]}]]></xp:this.value>
<xp:text escape="false" id="computedField2">
<xp:this.value><![CDATA[#{javascript:rowDataSub[0]}]]></xp:this.value>
</xp:text>
<xp:text escape="false" id="computedField3">
<xp:this.value><![CDATA[#{javascript:rowDataSub[1]}]]></xp:this.value>
</xp:text>
<xp:br></xp:br>
</xp:repeat>
<xp:br></xp:br>
</xp:repeat>
</xp:view>


As a data I'm using array scopeVariable. It works perfect for parent repeat and shows scopeVariable data in computed field computedField1. For nested repeat I use an array that is third element of scopeVariable. But nested repeat doesn't show anything in computed field computedField2. Is anything wrong with my repeats?

Answer

Change this line of code

    <xp:this.value><![CDATA[#{javascript:rowDataSub}]]></xp:this.value>

The nested repeat control runs already over all entries in sub array.
So, access current entry with rowDataSub instead of rowDataSub[0].