I have an XPages custom control and want to add a required validator programmatically to a radioGroup in it, depending on a setting in the document being used (my code is below).
So I’ve added my radioGroup, and added a script block calling XSP.attachValidator, so the validation is triggered when I submit the page. (The submit actually saves all data sources and reloads the page with the next set of documents, but I don’t think this is relevant to my problem).
When I try to submit with no radio button selected, I get the error prompt, but then a javascript error, both in Firefox and Internet Explorer. In FireBug, I see the error is e.select is not a function. In Internet Explorer it points the source of the error to XSPClientDojo.
Has anyone encountered this, solved it, or got any ideas whether to fix it or work around it?
Is the validation code tryin to push me back to the required field, so failing because it’s a radio button?
Thanks
Paul
XPages code:
<xp:radioGroup id=“response” defaultValue=“#{ansDoc.Default}”
value="#{ansDoc.response}" layout="pageDirection">
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:ansDoc.getItemValue("aChoices")}]]></xp:this.value>
</xp:selectItems>
</xp:radioGroup>
<xp:scriptBlock id=“scriptBlock1”>
<xp:this.value><![CDATA[var convertInput = function() {
var userPrompt = "#{ansDoc.PromptMessage}";
if (userPrompt != "") {
new dijit.Tooltip({connectId: ["#{id:response}"], label: userPrompt});
}
if ("#{ansDoc.Mandatory}" == "Y") {
XSP.attachValidator("#{id:response}", new XSP.RequiredValidator("#{ansDoc.mandError}"));
}
};
XSP.addOnLoad(convertInput);
]]></xp:this.value>
</xp:scriptBlock>