1

I am trying to disable user selection in tag.

    <h:selectOneRadio id="wildcard"   value="#{NewService.isWildCard}" label="#{msg.org_IsWildCard}" readonly="true" layout="lineDirection">              
                                        <f:selectItem id="yes" itemLabel="YES" itemValue="1" />
                                        <f:selectItem id="no" itemLabel="NO" itemValue="0" />                                       
</h:selectOneRadio> 

However on my GUI I am still able to select radio button value. Please tell me what is wrong in the code..Also the BackingBean code is pretty simple..I am just passing 0 or 1 in backingBean...

Please guide me on how to disable user selection in

AngelsandDemons
  • 2,823
  • 13
  • 47
  • 70

3 Answers3

5

This is indeed unintuitive behaviour of the JSF-generated HTML <input type="radio"> element. There are basically 2 solutions to your problem:

  1. Use disabled="true" instead of readonly="true":

    <h:selectOneRadio disabled="true">
    
  2. Add an onclick handler which returns false:

    <h:selectOneRadio onclick="return false;">
    
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
2

Use the itemDisabled attribute in your selectItems:

<f:selectItem id="yes" itemLabel="YES" itemValue="1" itemDisabled="true"/>
Matt Handy
  • 29,855
  • 2
  • 89
  • 112
1
<h:selectOneRadio id="wildcard"   value="#{NewService.isWildCard}" label="#{msg.org_IsWildCard}" readonly="true" layout="lineDirection">              
     <f:selectItem id="yes" itemLabel="YES" itemValue="1" itemDisabled="#{NewService.type == 1 }"/>
     <f:selectItem id="no" itemLabel="NO" itemValue="0" itemDisabled="#{NewService.type == 1 }"/>
</h:selectOneRadio> 
May Thet
  • 61
  • 4