I have a flex MXML UI that is building a set of radio buttons using the Repeater
component:
<mx:Repeater id="radios"
dataProvider="{_lists.(@id == _question.single.@response_list).group.listItem}">
<mx:RadioButton groupName="responses"
label="{radios.currentItem.@text}"
data="{radios.currentItem.@level}"/>
</mx:Repeater>
What I want to do is have the component within the repeater -- the RadioButton
in this example -- be chosen based on the value of a property of radios.currentItem
: If the value of currentItem
is "foo", for example, I want a Button
there, or if it's "bar" I want a RadioButton
. Is it possible to perform this kind of conditional construction in an MXML component, or must I revert to ActionScript to do it?
I'm thinking of something along these lines:
<mx:Repeater id="r" dataProvider="{list}">
<mx:If test="{r.currentItem.@type == 'radio'}">
<mx:RadioButton label="{r.currentItem.@text}" />
</mx:If>
<mx:If test="{r.currentItem.@type == 'specify'}">
<custom:Specify label="{r.currentItem.@text}" />
</mx:If>
</mx:Repeater>