So I found out the other day that an XPages Radio Button Group idTag is not resolved using the server side #{id:RadioButtonGroup}

Creates the following HTML on the webpage (in this example my RadioButtonGroup is called CertNextYearNeeded)
<label class="xspRadioButton" for="view:_id1:_id2:_id18:radio1"> <input id="view:_id1:_id2:_id18:radio1" type="radio" name="view:_id1:_id2:_id18:CertNextYearNeeded" value="No" />No</label <label class="xspRadioButton" for="view:_id1:_id2:_id18:radio2"> <input id="view:_id1:_id2:_id18:radio2" type="radio" name="view:_id1:_id2:_id18:CertNextYearNeeded" value="Yes"/>Yes</label>
however using the # notation in my SSJS I got the following….(Using x$)
x$("#{id:CertNextYearNeeded}", ":checked").val()!="Yes"
came through into the webpage source code as
x$(":checked").val()!="Yes"
so therefore we need to select by name (which I don’t like as it could be ambiguous, but have no choice) you have to select the radio button group by name (don’t use x$). In this case we are testing to see if “Yes” has been selected – No or no selection at all will fail.
if ($("[name$=CertNextYearNeeded]:checked").val() != 'Yes') { msg="Select the option\n"; }
- [name$=CertNextYearNeeded] <— Selects all elements with a name like *CertNextYearNeeded
- :checked <—- get the checked
- element .val() <— get the value
Hi,
to access the group name of a radio button in SSJS you can do the following:
#{javascript:getComponent(“radio1”).getClientGroupName( facesContext, getComponent(“radio1”))}
Sven
Sven – thanks for the response – Genius !! That is really good to know !
alert(“#{javascript:getComponent(“radio1”).getClientGroupName( facesContext, getComponent(“radio1″))}”)
response: view:_id1:_id2:_id18:CertNextYearNeeded
saying that – this is now rather ugly code and I might just stick with the original
“x$([name$=”+#{javascript:getComponent(“radio1”).getClientGroupName( facesContext, getComponent(“radio1″))}+”]:checked”)
or
$(“[name$=CertNextYearNeeded]:checked”)
both return the same jQuery object
thanks again!