This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Apr 27, 2011, 1:10 PM
66 Posts

Disable Click on Label(s) for Radio Buttons

  • Category: Other
  • Platform: All
  • Release: 8.5.2
  • Role: Developer
  • Tags:
  • Replies: 6
In XPages I've found that when using events (onClick and a partial refresh) and clicking on the label of a radio button in a radio button group causes unintended results. Clicking on the label of a radio button causes the value not to "stick" after the partial refresh of the page. It changes back to the previously selected value. However, if you click the radio button itself, the value will update correctly.

This is explained rather nicely here:  http://www-10.lotus.com/ldd/nd85forum.nsf/ShowMyTopicsAllFlatweb/5be066a529abcb698525773d005ce7c1?OpenDocument
 
My question is, would it be possible to not allow a click on the label, and require the user to click on the radio button?
 
Thanks for any suggestions.
Apr 27, 2011, 4:47 PM
129 Posts
Re: Disable Click on Label(s) for Radio Buttons
I think I had the same problem a while back.. Have you tried using onmouseup? Same result?
 
Not sure if this is the way I worked around the problem, but it could be worth a try :)
Apr 27, 2011, 5:32 PM
66 Posts
Re: Disable Click on Label(s) for Radio Buttons
Hi Tommy,
 
I tried onmouseup and that is worse. It doesn't keep the value on either click of the label or click of the radio button after the partial update. Thanks for the suggestion though!
Apr 28, 2011, 12:25 PM
38 Posts
Re: Disable Click on Label(s) for Radio Buttons
The problem here is that XPage generates <label> tag around the radiobutton. For e.g. for the following XPage code snippet:
 
<xp:radioGroup id="radioGroup1">
<xp:selectItem itemLabel="value1" itemValue="value1"></xp:selectItem>
<xp:selectItem itemLabel="value2" itemValue="value2"></xp:selectItem>
<xp:selectItem itemLabel="value3" itemValue="value3"></xp:selectItem>
</xp:radioGroup> 
 
this HTML is generated: 
 
<table id="view:_id1:radioGroup1" class="xspRadioButton">
<tr><td><label><input type="radio" name="view:_id1:radioGroup1" value="value1">value1</input></label></td>
<td><label><input type="radio" name="view:_id1:radioGroup1" value="value2"> value2</input></label></td>
<td><label><input type="radio" name="view:_id1:radioGroup1" value="value3"> value3</input></label></td></tr>
</table> 
 
I simply could not find any property that would disable this <label> tag generation. So what I did was to create separate radiobuttons without labels and put them separately as plain text in XPage. Crude solution but it works! Something like this 
<xp:radio id="radio1" groupName="myRadioGroup"></xp:radio>Label1
<xp:radio id="radio2" groupName="myRadioGroup"></xp:radio>Label2 
 
Just make sure the groupName attribute is same for all radio buttons. 
 
Hope it helps!
Apr 28, 2011, 5:24 PM
66 Posts
Re: Disable Click on Label(s) for Radio Buttons
Naveen,
 
I tried your method. Unfortunately I can't get it to work with partial refreshes either. After selecting a radio button, the onclick (tried onmouseup also) event fires and does a partial update and the radio button loses its value. Were you able to get it to work after a partial update?
May 11, 2011, 2:25 PM
66 Posts
Re: Disable Click on Label(s) for Radio Buttons
If anyone comes across this in the future...I ended up using the Dojo radio buttons. They do not have this issue.
Aug 2, 2011, 2:25 PM
64 Posts
dijit.form.RadioButton does not fix this for me...
 - I've been wrestling with this same issue, which was initially discovered while using dijits, and shown to persist when using <xp:radioGroup>.
- The <label> are in fact normal legacy use of a radio button, which is why they are emitted.  The only way I could get it to work is to build the same exact table structure as the <xp:radioGroup> control emits, but do it "manually" and use <xp:radio> directly.  Then it's perfect, if woefully static.
- But this approach does not work in a custom control, where the "groupName" attribute is computed.  The XPage automagically mangles that so every radio button has an unique name attribute on render, which destroys their grouping.  So far I have not found a way around this.

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal