I have an xpages where I have a repeat control and I added a button to increment the number of repeats. Within the repeat I have an inputText and a ComputedField. I want to get the ID of each inputText and do something with it, maybe add them. I added an index to the repeat and the label of my inputText is: input$(index). I want to access with getComponent("input"+index) but it says: getComponent is null. Why?
What is the inputText id?
P.S. This is the code:
<xp:this.beforePageLoad><![CDATA[#{javascript:sessionScope.dynaField=parseInt("1")}]]></xp:this.beforePageLoad>
<xp:div style="text-align:center">
<xp:inputText id="number" defaultValue="100">
<xp:this.converter>
<xp:convertNumber type="number" integerOnly="true"></xp:convertNumber>
</xp:this.converter>
</xp:inputText></xp:div>
<xp:panel id="Panel_All" style="text-align:center">
<xp:repeat id="repeat1" var="testCollection" indexVar="index"
value="#{javascript:parseInt(sessionScope.dynaField)}" rows="120"
style="border:1pt" repeatControls="false" first="0">
<xp:inputText id="input${index}">
<xp:eventHandler event="onchange" submit="true"
refreshMode="partial" refreshId="repeat1">
</xp:eventHandler>
</xp:inputText>
<xp:text escape="true" id="comp">
<xp:this.value><![CDATA[#{javascript:var repeatValue = getComponent("repeat1").getValue();
var number1 = getComponent("number").getValue();
var number2 = getComponent("input").getValue();
return number1-number2;
}]]></xp:this.value>
</xp:text>
<xp:br></xp:br></xp:repeat>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:table style="width:100%">
<xp:tr>
<xp:td colspan="2" style="text-align:center">
<xp:button value="Add Document" id="button1">
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" refreshId="Panel_All">
<xp:this.action><![CDATA[#{javascript:sessionScope.dynaField=parseInt(sessionScope.dynaField)+1
getComponent("repeat1").setValue(parseInt(sessionScope.dynaField));}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
</xp:td>
</xp:tr>
</xp:table>
</xp:panel>
I have the first inputText with the id number, where is the initial number. Then the repeat have an input text and a computed field that shows the difference between the "number", first inputText and the inputText in the repeat. Then if the user clicks the button a new inputText shows in the repeat and the computed field related to that field the result should be: (number)-1st inputText in the repeat - 2nd inputText in the field.
Thanks,
Florin