You need to sign in to do that
Don't have an account?
@GM
Error: Compile Error: Constructor not defined: [wrapperText].<Constructor>(SOBJECT:question__c, String) at line 11 column 22
please suggest,
controller----->
public class sampleCon {
public string answer = '';
public List<wrapperText> textWrap {get;set;} {textWrap = new List<wrapperText>();}
public sampleCon(){
for(Question__c ques : [Select id,Name,question__c,Option_1__c,Option_2__c from question__c] ) {
textWrap.add(new wrapperText (ques , answer));
system.debug('---------********----11----->'+textWrap);
}
}
public string getAnswer() {
return answer;
}
public void setAnswer(string answer) {
{this.answer= answer;}
}
public List<Question__c>getQuestion (){
List<Question__c>listQuestion=[Select id,Name,question__c,Option_1__c,Option_2__c from question__c];
return listQuestion;
}
public PageReference test() {
system.debug('------------------>'+answer);
return null;
}
public List<Question__c>listQuestion{get;set;}
/*
public List<wrapperText> gettextWrap (){
List<wrapperText> wrpTxt = new List<wrapperText>();
for(Question__c ques : [Select id,Name,question_detail__c,Option_1__c,Option_2__c from question__c] ) {
system.debug('-------------11----->'+wrpTxt);
wrpTxt.add(new wrapperText (ques , answer));
}
return wrpTxt;
}
*/
}
vf page--->
<apex:page controller="sampleCon" >
<apex:form id="theForm">
<apex:outputPanel id="str">
</apex:outputPanel>
<script>
function test1(id)
{
var theRadioButtonSet = document.getElementById(id);
if (theRadioButtonSet.checked){
//alert('You Checked : '+theRadioButtonSet.value);
radiovalue(theRadioButtonSet.value);
}
}
</script>
<apex:actionfunction name="radiovalue" rerender="str">
<apex:param name="radio" value="{!answer}"/>
</apex:actionFunction>
<!------- New PageBlock Line ------------------------------------------>
<apex:pageblock >
<apex:dataList id="Datalist1" value="{!textWrap}" var="Dlist" rows="2">
<!-- <apex:outputField label="Question" value="{!Dlist.ques.question_detail__c}"/><br/> -->
<apex:selectRadio id="SelectRadio1" onchange="test1(this.id);" value="{!Dlist.val}" >
<!-- <apex:selectOption itemValue="india" itemLabel="India" />
<apex:selectOption itemValue="ap" itemLabel="AP" /> -->
<apex:selectoption itemlabel="{!Dlist.ques.Option_1__c}" itemvalue="{!Dlist.ques.Option_1__c}" />
<br/>
<apex:selectoption itemlabel="{!Dlist.ques.Option_2__c}" itemvalue="{!Dlist.ques.Option_2__c}" />
</apex:selectRadio>
<apex:outputPanel id="out">
<p>You have selected:
<apex:outputText value="{!Dlist.val}"/></p>
<br/>
</apex:outputPanel>
<apex:commandButton value="Submit" action="{!test}" rerender="out" status="status" />
</apex:dataList>
</apex:pageBlock>
</apex:form>
</apex:page>
controller----->
public class sampleCon {
public string answer = '';
public List<wrapperText> textWrap {get;set;} {textWrap = new List<wrapperText>();}
public sampleCon(){
for(Question__c ques : [Select id,Name,question__c,Option_1__c,Option_2__c from question__c] ) {
textWrap.add(new wrapperText (ques , answer));
system.debug('---------********----11----->'+textWrap);
}
}
public string getAnswer() {
return answer;
}
public void setAnswer(string answer) {
{this.answer= answer;}
}
public List<Question__c>getQuestion (){
List<Question__c>listQuestion=[Select id,Name,question__c,Option_1__c,Option_2__c from question__c];
return listQuestion;
}
public PageReference test() {
system.debug('------------------>'+answer);
return null;
}
public List<Question__c>listQuestion{get;set;}
/*
public List<wrapperText> gettextWrap (){
List<wrapperText> wrpTxt = new List<wrapperText>();
for(Question__c ques : [Select id,Name,question_detail__c,Option_1__c,Option_2__c from question__c] ) {
system.debug('-------------11----->'+wrpTxt);
wrpTxt.add(new wrapperText (ques , answer));
}
return wrpTxt;
}
*/
}
vf page--->
<apex:page controller="sampleCon" >
<apex:form id="theForm">
<apex:outputPanel id="str">
</apex:outputPanel>
<script>
function test1(id)
{
var theRadioButtonSet = document.getElementById(id);
if (theRadioButtonSet.checked){
//alert('You Checked : '+theRadioButtonSet.value);
radiovalue(theRadioButtonSet.value);
}
}
</script>
<apex:actionfunction name="radiovalue" rerender="str">
<apex:param name="radio" value="{!answer}"/>
</apex:actionFunction>
<!------- New PageBlock Line ------------------------------------------>
<apex:pageblock >
<apex:dataList id="Datalist1" value="{!textWrap}" var="Dlist" rows="2">
<!-- <apex:outputField label="Question" value="{!Dlist.ques.question_detail__c}"/><br/> -->
<apex:selectRadio id="SelectRadio1" onchange="test1(this.id);" value="{!Dlist.val}" >
<!-- <apex:selectOption itemValue="india" itemLabel="India" />
<apex:selectOption itemValue="ap" itemLabel="AP" /> -->
<apex:selectoption itemlabel="{!Dlist.ques.Option_1__c}" itemvalue="{!Dlist.ques.Option_1__c}" />
<br/>
<apex:selectoption itemlabel="{!Dlist.ques.Option_2__c}" itemvalue="{!Dlist.ques.Option_2__c}" />
</apex:selectRadio>
<apex:outputPanel id="out">
<p>You have selected:
<apex:outputText value="{!Dlist.val}"/></p>
<br/>
</apex:outputPanel>
<apex:commandButton value="Submit" action="{!test}" rerender="out" status="status" />
</apex:dataList>
</apex:pageBlock>
</apex:form>
</apex:page>
// Constructor
public WrappreText(Question__c ques, String ans) {
//#todo
}
i have refered this link ----https://developer.salesforce.com/forums/ForumsMain?id=906F00000009tyFIAQ
my requiremment is as same as mentioned in the above link
thank you.
this is the WrapperText class,
public with sharing class wrapperText{
public string answer='';
public Question__c ques;
public List<wrapperText> textWrap = new List<wrapperText>();
public wrapperText(Question__c ques, String ans)
{
for(Question__c ques1 : [Select id,Name,question__c,Option_1__c,Option_2__c from question__c] ) {
textWrap.add(new wrapperText (ques1 , answer));
system.debug('---------********----11----->'+textWrap);
}
}
}
controller----
public class sampleCon1 {
public string answer = '';
public List<wrapperText> textWrap {get;set;} {textWrap = new List<wrapperText>();}
public sampleCon1(){
for(Question__c ques : [Select id,Name,question__c,Option_1__c,Option_2__c from question__c] ) {
textWrap.add(new wrapperText (ques , answer));
system.debug('---------********----11----->'+textWrap);
}
}
public string getAnswer() {
return answer;
}
public void setAnswer(string answer) {
{this.answer= answer;}
}
public List<Question__c>getQuestion (){
List<Question__c>listQuestion=[Select id,Name,question__c,Option_1__c,Option_2__c from question__c];
return listQuestion;
}
public PageReference test() {
system.debug('------------------>'+answer);
return null;
}
public List<Question__c>listQuestion{get;set;}
/*
public List<wrapperText> gettextWrap (){
List<wrapperText> wrpTxt = new List<wrapperText>();
for(Question__c ques : [Select id,Name,question_detail__c,Option_1__c,Option_2__c from question__c] ) {
system.debug('-------------11----->'+wrpTxt);
wrpTxt.add(new wrapperText (ques , answer));
}
return wrpTxt;
}
*/
}
BUT I"M getting following error in VF page
Error: Unknown property 'wrapperText.val'
<apex:page controller="sampleCon1">
<apex:form id="theForm">
<apex:outputPanel id="str">
</apex:outputPanel>
<script>
function test1(id)
{
var theRadioButtonSet = document.getElementById(id);
if (theRadioButtonSet.checked){
//alert('You Checked : '+theRadioButtonSet.value);
radiovalue(theRadioButtonSet.value);
}
}
</script>
<apex:actionfunction name="radiovalue" rerender="str">
<apex:param name="radio" value="{!answer}"/>
</apex:actionFunction>
<!------- New PageBlock Line ------------------------------------------>
<apex:pageblock >
<apex:dataList id="Datalist1" value="{!textWrap}" var="Dlist" rows="2">
<!-- <apex:outputField label="Question" value="{!Dlist.ques.question_detail__c}"/><br/> -->
<apex:selectRadio id="SelectRadio1" onchange="test1(this.id);" value="{!Dlist.val}" >
<!-- <apex:selectOption itemValue="india" itemLabel="India" />
<apex:selectOption itemValue="ap" itemLabel="AP" /> -->
<apex:selectoption itemlabel="{!Dlist.ques.Option_1__c}" itemvalue="{!Dlist.ques.Option_1__c}" />
<br/>
<apex:selectoption itemlabel="{!Dlist.ques.Option_2__c}" itemvalue="{!Dlist.ques.Option_2__c}" />
</apex:selectRadio>
<apex:outputPanel id="out">
<p>You have selected:
<apex:outputText value="{!Dlist.val}"/></p>
<br/>
</apex:outputPanel>
<apex:commandButton value="Submit" action="{!test}" rerender="out" status="status" />
</apex:dataList>
</apex:pageBlock>
</apex:form>
</apex:page>
BUT I"M getting following error in VF page
Error: Unknown property 'wrapperText.val
you doesn't Initalized string variable propely. you wrote
public string answer = '';
you opened quotes but doesn't end it.
make it as
public string answer = ''";
{
f
or(Question__c ques1 : [Select id,Name,question__c,Option_1__c,Option_2__c from question__c] ) {textWrap.add(new wrapperText (ques1 , answer));system.debug('---------********----11----->'+textWrap);
}
}
}
you writed infinite loop."new wrapperText (ques1 , answer)" in the for loop again calls the constuctor that will calls one more constuctor this never ends. check your debug logs once.