You need to sign in to do that
Don't have an account?
SamirS
I have have designed a vf page with two radio button. I have created a field of type checkbox. I want to store boolean value against the radio button. Please help me.
Here is my VF page:
Here is my Controller
<apex:page standardStylesheets="false" controller="RadioButtonTestController" showHeader="false" sidebar="false"> <apex:form > <div align="center"> <apex:selectRadio value="{!Country}" > India <apex:selectOption itemValue="true"></apex:selectOption> China <apex:selectOption itemValue="false"></apex:selectOption> <apex:actionSupport event="onchange" action="{!checkSelectedValue}" reRender="none"/> </apex:selectRadio> <apex:commandButton value="Show country" action="{!showCountry}"/> </div> </apex:form> </apex:page>
Here is my Controller
public class RadioButtonTestController { public Boolean Country{get; set;} public void checkSelectedValue() { system.debug('Selected value is: '+ Country); } public void showCountry() { String caseId = ApexPages.currentPage().getParameters().get('CaseID'); list<Storing_Location__c> str = [Select Country__c from Storing_Location__c where CaseNumID__c=: caseId]; Storing_Location__c obj = new Storing_Location__c(); if(str.size()>0) { obj.Id = str[0].Id; } obj.Country__c = Country; system.debug('Selected value is:***********************:::'+Country); } }
In your vf page the code should be. In your code itemValue was set to true or false, in order to get the value you have to give the itemValue.
And also, in your controller the make the country string instead of boolean
public String Country{get; set;}
Let me know if you still have any issues.
Thanks
Pramodh.
If the size of str is zero then it will create a new record or it will update with the 0th index in the list
Thanks
Pramodh
Your code is working fine it sets the value for INdia as true and china as false. Do one change in your constructor so that on load of page you will also get the value of boolean
Let me know if this helps.
Thanks,
Sukanya Banekar