In a repeat (var=row, indexVar=rownumber) ,I can't get the the defaultselected to work . The return value becomes correctly "true" but doesn't work.
The idea is that 1 radio from this radiogroup ("selection") is preselected, based on the value in the viewScope selectie.
<xp:radio id="radio1" value="#{viewScope.test}" groupName="selection">
<xp:this.text><![CDATA[#{javascript:row[3]}]]>
</xp:this.text>
<xp:this.defaultSelected><![CDATA[#{javascript:var check = "no";
try{
for (i=0;i<25;i++){
if( @IsMember(row[4],viewScope.selectie[0][i])==1){var
check="true";break}//only 1 can be checked
}//end for i
if (check=="true"){return true}
else {return false}
}//end try
catch (e){
sessionScope.error = "error radio1 :"+e.toString();}}]]>
</xp:this.defaultSelected>
<xp:eventHandler event="onchange" submit="true" refreshMode="partial"
refreshId="resultPanel">
<xp:this.action><![CDATA[#{javascript:var item
=viewScope.lijnknr.intValue();
viewScope.selectie[0].set(item,row[4]);}]]>
</xp:this.action>
</xp:eventHandler>
</xp:radio>
EDIT
I added following line : <xp:this.selectedValue><![CDATA[#{javascript:row[4]}]]></xp:this.selectedValue>
since I read following post : Xpages radio btn group checked
but it still doesn't work .....
SECOND EDIT added another property : skipContainers="1" as found in "Mastering Xpages",
but still doesn't work ....
@IsMember
search forrow[4]
inviewScope.selectie[0]
instead ofviewScope.selectie[0][i]
? Also, IMO the whole code for this property could be simplified toreturn (@IsMember(row[4],viewScope.selectie[0]) ? true : false)
. – xpages-noob@IsMember
? ifviewScope.selectie
already is the array that does or does not contain the valuerow[4]
, the code for defaultSelected should just be#{javascript:return (@IsMember(row[4],viewScope.selectie)==1 ? true : false);}
. – xpages-noobviewScope.test
and thus defaultSelected might not apply anymore. Also, instead of using a repeat control with single radio elements, I recommend using the approach with the radioGroup element that has been suggested by @shillem in his answer below. – xpages-noob