I have a multivalue field containing an array of values on an Xpage. A repeat control on the same Xpage creates a text field for each value in the array.
The text field is in its own custom control (called "namesField") and looks like this:
<xp:inputText
value="#{compositeData.dataSource[compositeData.fieldName]}"
style="width:300px">
</xp:inputText>
The custom control has two custom properties: "dataSource" and "fieldName" (both strings).
On the Xpage the I put the "namesField" custom control inside the repeat control like this (reqDoc.RoutingStages is the array of values from the multivalue field):
<xp:repeat
value="#{reqDoc.RoutingStages}" var="stage"
indexVar="stageIndex" id="ApproversRepeat">
<tr>
<td>
<!-- field label -->
<xp:text escape="true"
id="ApprovalStage"
value="#{reqDoc.RoutingStages[stageIndex]}">
</xp:text>
</td>
<td>
<xc:namesField dataSource="#{reqDoc}"
fieldName="ApproverName_#{stageIndex}">
</xc:namesField>
</td>
</tr>
</xp:repeat>
This works absolutely great! An input field is created for each value in the array and the values in each text field are successfully saved to the backend doc. For example, if the array contains 4 values I get four text fields. This is exactly what I want, however I want to store user names in the text fields and I want them entered using a name picker for each field.
Fired with enthusiasm I added a name picker to the "namesField" custom control. The stumbling block is adding an id to the inputText field so that the name picker can be bound to it. I have tried computing the id in the "namesField" custom control but apparently this is not allowed (if I put id="#{compositeData.fieldName}" in the text field it causes the error "The value of the property id cannot be a run time binding").
I have tried many different ways of trying working out the ids of the text fields. The latest thing I have tried is this
<xe:namePicker id="approverPicker"
dialogTitle="Select an approver" for="${javascript:'#{javascript:reqDoc[\'ApproverName_\' + stageIndex.toString()]}'}">
.........
.........
</xe:namePicker>
This does not work!
So, does anyone know how I tell the namePicker which field it is tied to?
namesField? Because if it is inside the custom control then you just need to setidfor input text. Like if the input text field is<xp:inputText id="inputText4" .....></xp:inputText>then name picker can be<xe:namePicker id="namePicker1" for="inputText4" .....></xe:namePicker>- Naveenid="nameField"to my inputText field andfor="nameField"to my namePicker (both on the "namesField" custom control). It works! Thanks for your help and for showing me I need to "think simple" rather than "think complex" :) - Rob Weddell