Add a selectItems
property to radioGroup
which reads additional options from a viewScope. Set the viewScope in button and add a new option with Java object SelectItem
with label and value:
<xp:radioGroup id="radioGroup1" layout="lineDirection">
<xp:selectItem itemLabel="1" itemValue="1"></xp:selectItem>
<xp:selectItem itemLabel="2" itemValue="2"></xp:selectItem>
<xp:selectItem itemLabel="3" itemValue="3"></xp:selectItem>
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:viewScope.selectItems}]]></xp:this.value>
</xp:selectItems>
</xp:radioGroup>
<xp:button
value="Add option"
id="button1">
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:
if (!viewScope.selectItems) {
viewScope.selectItems = [];
}
viewScope.selectItems.add(new javax.faces.model.SelectItem("Value1", "Label1"));
}]]></xp:this.action>
</xp:eventHandler></xp:button>