I have many controls that do this and I have tried several different techniques over the years based on what I saw on blogs, presentations, etc.
Here is what is working for me...
1. Put the field on a Custom Control
2. Add string property to the Custom Control
3. Set the binding to get the field name from the property.
4. Provide the value to the string property when it is used (works fine in a repeat control).
Example:
<xp:radioGroup id="radioGroup2">
<xp:this.value><![CDATA[#{document1[compositeData.fieldName]}]]></xp:this.value>
<xp:selectItems id="selectItems2">
<xp:this.value><![CDATA[#{javascript:@DbLookup(blahblahblah)}]]></xp:this.value>
</xp:selectItems>
</xp:radioGroup>
I know others have said you could also dynamically set the data source but I have tried many different versions of that and have not been successful.
If anyone has a working bit of code they could post that would be fantastic.