You need to sign in to do that
Don't have an account?
jayesh pagare
Urgent Help for get option value in apex wrapper class
Hi All,
I have one master table"Question" and child table "Option" now here i want to show questions and its related options( with radio button) in vf page and get option value for respective question. I am able to fetch question and option on vf page but didnt able to pass option value to apex class.Pls Help..
<apex:page Tabstyle="Account" controller="WOS_WrapperExample">
<apex:form >
<div>
<table>
<tr>
<th>Select</th>
<th>Question</th>
</tr>
<apex:repeat value="{!Quest_OptionList}" var="a">
<tr> <td>{!a.acc.Name}</td> </tr>
<apex:repeat value="{!a.acc.Option__r}" var="o">
<tr> <td><apex:inputCheckbox value="{!a.selected}" id="checkedone" /></td>
<td id="theIDD" >{!o.name}</td>
</tr>
</apex:repeat>
</apex:repeat>
</table>
</div>
</apex:form>
</apex:page>
Apex Class :
public class WOS_WrapperExample
{
public List<QuestionOptionWrap> Quest_OptionList {get;set;}
public List<QuestionData__c> selectedQuestions {get;set;}
public WOS_WrapperExample() {
Quest_OptionList = new list<QuestionOptionWrap>();
selectedQuestions = new list<QuestionData__c>();
for(QuestionData__c a : [select Id, Name,(select name from Option__r) from QuestionData__c limit 10])
Quest_OptionList .add(new QuestionOptionWrap(a));
}
public PageReference Selectedacc()
{
selectedQuestions.clear();
for(QuestionOptionWrap accwrapper : Quest_OptionList )
if(accwrapper.selected == true)
selectedQuestions.add(accwrapper.acc);
return null;
}
public class QuestionOptionWrap
{
public QuestionData__c acc{get; set;}
public String optionOne{get; set;}
public QuestionOptionWrap(QuestionData__c a) // Constructor of wrapper class
{
acc = a;
selected = false;
}
}
}
I have one master table"Question" and child table "Option" now here i want to show questions and its related options( with radio button) in vf page and get option value for respective question. I am able to fetch question and option on vf page but didnt able to pass option value to apex class.Pls Help..
<apex:page Tabstyle="Account" controller="WOS_WrapperExample">
<apex:form >
<div>
<table>
<tr>
<th>Select</th>
<th>Question</th>
</tr>
<apex:repeat value="{!Quest_OptionList}" var="a">
<tr> <td>{!a.acc.Name}</td> </tr>
<apex:repeat value="{!a.acc.Option__r}" var="o">
<tr> <td><apex:inputCheckbox value="{!a.selected}" id="checkedone" /></td>
<td id="theIDD" >{!o.name}</td>
</tr>
</apex:repeat>
</apex:repeat>
</table>
</div>
</apex:form>
</apex:page>
Apex Class :
public class WOS_WrapperExample
{
public List<QuestionOptionWrap> Quest_OptionList {get;set;}
public List<QuestionData__c> selectedQuestions {get;set;}
public WOS_WrapperExample() {
Quest_OptionList = new list<QuestionOptionWrap>();
selectedQuestions = new list<QuestionData__c>();
for(QuestionData__c a : [select Id, Name,(select name from Option__r) from QuestionData__c limit 10])
Quest_OptionList .add(new QuestionOptionWrap(a));
}
public PageReference Selectedacc()
{
selectedQuestions.clear();
for(QuestionOptionWrap accwrapper : Quest_OptionList )
if(accwrapper.selected == true)
selectedQuestions.add(accwrapper.acc);
return null;
}
public class QuestionOptionWrap
{
public QuestionData__c acc{get; set;}
public String optionOne{get; set;}
public QuestionOptionWrap(QuestionData__c a) // Constructor of wrapper class
{
acc = a;
selected = false;
}
}
}
Use the actionFunction, on clicking of Checkbox call the method "Selectedacc" in actionFunction Action.
Hope below code helps you call the controller method.
<script>
function callSelectedacc()
{
selectedAcc();
}
</script>
<apex:actionFunction action="{!selectedacc}" name="selectedAcc" reRender="tableId"/>
<apex:inputCheckbox value="{!a.selected}" onclick="callSelectedacc();return false;" />
Thanks,
Pramod