Attach Validator to RadioGroup in XPages

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>

Subject: e.select() error

I’ve found were the e.select() error is, by accidentally coming across this article.

http://www-10.lotus.com/ldd/ddwiki.nsf/dx/Client_Side_JavaScript_Libraries_in_XPages.htm

This is in the default XSP.validationError function. As you will see, the final line is e.select.

After lots of investigation (you’ll see other posts on this forum about the problems I’ve had getting other solutions to work), I’ve got a resolution and will be posting it shortly as a series of articles on my blog (http://hermes.intec.co.uk/intec/blog.nsf - the blog is not yet active).