function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Prasanth SrinivasanPrasanth Srinivasan 

issue in getting the value of CheckBox value in apex from visualforce

Hi Folks,

I have a Boolean value in my controller.
public Boolean withoutDocument {get;set;}
I have referred them in the visual force page like this.
when I try to get the value in my controller.
It is throwing the Run time error that the argument cannot be null.

Any help is much appreciated.

thank you.
Mahesh DMahesh D
Hi Prasanth,

Please paste you full code so that we can able to help you.

Regards,
Mahesh
Prasanth SrinivasanPrasanth Srinivasan
Hi Mahesh, 
Please find my code at 
http://salesforce.stackexchange.com/questions/114246/issue-in-getting-the-value-of-checkbox-value-in-apex-from-visualforce
Mahesh DMahesh D
Hi Prasanth,

I would like to suggest to use the selectRadio.

apex:selectRadio
A set of related radio button input elements, displayed in a table. Unlike checkboxes, only one radio button can ever be selected at a time.
 
<!-- Page: -->
<apex:page controller="sampleCon">
    <apex:form>
        <apex:selectRadio value="{!country}">
            <apex:selectOptions value="{!items}"/>
            </apex:selectRadio><p/>
            <apex:commandButton value="Test" action="{!test}" rerender="out" status="status"/>
     </apex:form>
     <apex:outputPanel id="out">
          <apex:actionstatus id="status" startText="testing..."> 
             <apex:facet name="stop"> 
               <apex:outputPanel> 
                  <p>You have selected:</p> 
                 <apex:outputText value="{!country}"/> 
              </apex:outputPanel> 
            </apex:facet> 
          </apex:actionstatus> 
     </apex:outputPanel> 
</apex:page>
            
/*** Controller ***/
public class sampleCon {
    String country = null;
         
    public PageReference test() {
        return null;
    }
                
    public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>(); 
        options.add(new SelectOption('US','US')); 
        options.add(new SelectOption('CANADA','Canada')); 
        options.add(new SelectOption('MEXICO','Mexico')); return options; 
    }
                   
    public String getCountry() {
        return country;
    }
                    
    public void setCountry(String country) { this.country = country; }
}

Please do let me know if it works.

Regards,
Mahesh