I have a repeat control and populating a checkboxgroup with items from a viewScope array. Sample code is :
<xp:repeat id="repeat4" rows="100" value="#{viewScope.choices}"
indexVar="rownumber" var="row" first="0">
<xp:checkBoxGroup id="checkBoxGroup2" layout="lineDirection">
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:if (viewScope.choices[rownumber].get(1)==viewScope.line){
return viewScope.choices[rownumber].get(0)
}}]]></xp:this.value>
</xp:selectItems>
</xp:checkBoxGroup>
<xe:tooltip id="tooltip1" for="checkBoxGroup2">
<xe:this.label><![CDATA[#{javascript:return viewScope.choices[rownumber].get(1)}]]></xe:this.label>
</xe:tooltip>
</xp:repeat>
I'm reading the checked values with : @Text(getComponent("checkBoxGroup2").getSubmittedValue());
The problem is that it seems I can only read the last selected/ deselected value this way.
I guess it has something to do with the selecteditems that isn't returning an array, but how can I return an array with the given data ?
You can't use
checkBoxGroup
in this case. Every checkBoxGroup created by repeat is an own control and they are not connected to each other.Use a simple
checkBox
control instead and write the selected values in view scope variable array:The result is in
viewScope.selected
then.