You need to sign in to do that
Don't have an account?
Nitish 73
Dynamic Radio buttons on Visualforce
Hello All,
I have a requirement where I need to present a Master detail objects in the form of a question(master) and radio button options (detail)
Example:
1. What is the Capital of USA
Here the Master record is the Question and the Child options are the detail records.
I have achieved half of it, but I am finding difficulty associating the detail records to their respective masters on the VF page
Here is the code
I would be grateful if anyone could help me out with this.
Thanks a lot
Nitish
I have a requirement where I need to present a Master detail objects in the form of a question(master) and radio button options (detail)
Example:
1. What is the Capital of USA
- Washington DC
- Newyork
- New Delhi
- Mumbai
- Hyderabad
- Bangalore
- Chennai
- Red
- Pink
- Yellow
Here the Master record is the Question and the Child options are the detail records.
I have achieved half of it, but I am finding difficulty associating the detail records to their respective masters on the VF page
Here is the code
<apex:page standardController="EFL_Inspection_Questionnaire__c" extensions="CARPOL_inspection_questionnaire" showHeader="true" > <h1>This is how the Questionnaire is going to look</h1> <apex:form > <apex:repeat value="{!qs}" var="q" id="theRepeat"> <apex:outputText value="{!q.Question__c}" id="question"/><br/> <apex:selectRadio value="{!country}"> <apex:selectOptions value="{!items}"/> </apex:selectRadio> <apex:inputField value="{!q.Comments__c}" style="width: 400px; height: 40px" id="comments"/><br/><br/><br/> </apex:repeat> </apex:form> </apex:page> **********************************************controller************************************* public class CARPOL_inspection_questionnaire { String country = null; List<EFL_Inspection_Questionnaire_Questions__c> questionnairequestions = new List<EFL_Inspection_Questionnaire_Questions__c>(); Id questionnaireid; public CARPOL_inspection_questionnaire(ApexPages.StandardController controller) { questionnaireid = ApexPages.currentPage().getParameters().get('id'); } public List<EFL_Inspection_Questionnaire_Questions__c> getqs() { questionnairequestions= [SELECT ID,NAME,Question__c,Comments__c,Answer__c FROM EFL_Inspection_Questionnaire_Questions__c WHERE EFL_Inspection_Questionnaire__c=:questionnaireid]; return questionnairequestions; } public List<SelectOption> getItems() { List<SelectOption> options = new List<SelectOption>(); List< EFL_Inspection_Questionnaire_Responses__c > responseoptions = new List< EFL_Inspection_Questionnaire_Responses__c >(); responseoptions = [SELECT ID,NAme, EFL_Inspection_Questionnaire_Questions__c, Response__c FROM EFL_Inspection_Questionnaire_Responses__c WHERE EFL_Inspection_Questionnaire_Questions__c IN:questionnairequestions]; for(EFL_Inspection_Questionnaire_Responses__c r:responseoptions){ options.add(new SelectOption(r.Response__c,r.Response__c)); } return options; } public String getCountry() { return country; } public void setCountry(String country) { this.country = country; } }
I would be grateful if anyone could help me out with this.
Thanks a lot
Nitish
You need to crate the wrapper class to associate the options only specific to the question.
Please try the below code. Hope this helps.
Thanks
Anupama
I was actually missing the idea of tying the question and answer together on the VF page. This wrapper helped a lot.
Really appreciate your help.
Thanks
Nitish
Regards
Anupama