Am unable to render the multiselect and singleselect in the vf page, suggest me to fix this.
code:
<apex:page standardController="Account" extensions="OnlineExAnswer" sidebar="false" showHeader="false">
<apex:form id="frm" >
<apex:pageBlock title="Questionare">
<apex:pageBlockSection columns="1">
<apex:repeat value="{!onWrprList }" var="qustwrpr">
<apex:outputField value="{!qustwrpr.que.Question_Des__c }" rendered="{!qustwrpr.que.Question_Type__c='Multi-Select'}"/>
<!-- <apex:outputField value="{!qustwrpr.que.Answer_Option__c}"/> -->
<apex:selectCheckboxes value="{!qustwrpr.ansList}">
<apex:selectOptions value="{!qustwrpr.anss}"/>
</apex:selectCheckboxes>
<!-- <apex:outputField value="{!qustwrpr.que.Question_Des__c }" rendered="{!qustwrpr.que.Question_Type__c='Single-Select'}"/>
<apex:selectRadio value="{!qustwrpr.ansList}">
<apex:selectOptions value="{!qustwrpr.anss}"/>
</apex:selectRadio> -->
</apex:repeat>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex:
public class OnlineExAnswer{
public List<Question__c> questionList {get; set;}
public List<OnlineWrapper> onWrprList {get; set;}
public List <String> ansList {get; set;}
private Account acc;
public OnlineExAnswer(ApexPages.StandardController Controller){
onWrprList=new List<OnlineWrapper>();
acc= (Account) controller.getrecord();
System.debug('::::::'+acc);
Account acc1=[Select Id,MasterSetAcc__c from Account where Id=:acc.Id Limit 1]; // with this query we can get fields of Account.
questionList= [Select Question_Des__c,Answer_Option__c, Question_Type__c from Question__c where MasterSet1__c=:acc1.MasterSetAcc__c];
for(Question__c que : questionList){
OnlineWrapper owrpr = new OnlineWrapper();
owrpr.que = que;
if(que.Question_Type__c == 'Multi-Select'){
system.debug('::::: answerOption String'+que.Answer_Option__c);
List<string> ansList=que.Answer_Option__c.split(';');
system.debug('########' + ansList);
for(String ans:ansList){
owrpr.anss.add(new selectOption(ans,ans));
}
system.debug('@@@@@@@@@@@@'+ owrpr.anss);
owrpr.isCheckBox= true;
}
else if(que.Question_Type__c == 'Single-Select'){
List<string> ansList=que.Answer_Option__c.split(';');
for(String ans:ansList){
owrpr.anss.add(new selectOption(ans,ans));
}
system.debug('^^^^^^^^^^^^'+ owrpr.anss);
owrpr.isRadiobutton= true;
}
else{
owrpr.isText= true;
}
onWrprList.add(owrpr);
}
system.debug('$$$$$$$$'+ questionList.size());
system.debug('%%%%%%%%'+ onWrprList.size());
}
public class OnlineWrapper{
public List<String> ansList {get; set;}
public List<SelectOption> anss{get;set;}
// public List<String> selectedOptions{get;set;}
public Question__c que {get; set;}
public Boolean isCheckBox {get;set;}
public Boolean isRadioButton {get;set;}
//public String text{get;set;}
public Boolean isText{get;set;}
public OnlineWrapper(){
ansList=new List<String>();
anss=new List<SelectOption>();
this.isCheckBox=false;
isRadioButton=false;
isText=false;
}
}
}