You need to sign in to do that
Don't have an account?
raj jordan
how to display objects in radio button?
Hi am trying to display account and contact object as radio buttons
when i click on account its record should display and
when i click on contact its record should display
but am not getting the required output
Below is my code
where it is only displaying contact details
please tell me where am going wrong
when i click on account its record should display and
when i click on contact its record should display
but am not getting the required output
Below is my code
where it is only displaying contact details
please tell me where am going wrong
<apex:page controller="radio16"> <apex:form > <apex:pageblock > <apex:selectRadio value="{!selectedRadio}"> <apex:selectOption itemLabel="Account" itemValue="Accounts"/> <apex:selectOption itemLabel="Contact" itemValue="Contacts"/> <apex:actionSupport event="onclick" action="{!getDetails}" reRender="records"/> </apex:selectRadio> <apex:outputPanel id="records"> <apex:pageblockSection Title="Records"> <apex:PageBlockTable value="{!acc}" var="a"> <apex:Column value="{!a.Name}"/> </apex:PageBlockTable> <apex:PageBlockTable value="{!con}" var="c"> <apex:Column value="{!c.lastname}"/> </apex:PageBlockTable> </apex:pageblockSection> </apex:outputPanel> </apex:pageblock> </apex:form> </apex:page>
public class radio16 { public String selectedRadio { get; set; } public List<Account> acc{get;set;} public List<Contact> con{get;set;} public PageReference getDetails(){ acc = new List<Account>(); if(selectedRadio== 'Account'){ acc = [SELECT name FROM Account limit 5]; } else{ con =new List<Contact>(); con = [SELECT lastname FROM Contact limit 5]; } return null; } }
Try this:
Class:
VF page:
Thanks
Vinod
All Answers
Try this:
Class:
VF page:
Thanks
Vinod