You need to sign in to do that
Don't have an account?
RossK
APEX:repeat tag - Not working with a list of objects where the objects are not sObjects
Hello!
I have a class that I created. The objects from this class are in a list and I am unable to display the list using the APEX repeat tag. See the code below. When I try to save the visualforce page, I get the following error.
Error: Unknown property 'repeatCon.objQuestion.Name'
My question is does Apex:Repeat support collections of non-SObject objects? If yes, what am I doing wrong? If not is there a work around?
<apex:page controller="repeatCon" id="thePage"> <apex:repeat value="{!listquestions}" var="q" id="theRepeat"> <apex:outputText value="{!q.Name}" id="theValue"/><br/> </apex:repeat > </apex:page> <!-- Controller --> public class repeatCon { public class objQuestion{ public string Name; public string SearchLabel; } public list<objQuestion> listquestions {get; set;} public repeatcon(){ listquestions = new list<objQuestion>(); objQuestion a = new objQuestion(); objQuestion b = new objQuestion(); a.name='a'; a.SearchLabel='a'; b.name='b'; b.SearchLabel='b'; listquestions.add(a); listquestions.add(b); } }
Thank you so much!!!
To answer you question... Yes, you can use the apex:repeat tag with objects that are not sObjects.
Now I think that you're getting an error because you haven't set a get method for the name variable in the objQuestion class. Try this:
All Answers
To answer you question... Yes, you can use the apex:repeat tag with objects that are not sObjects.
Now I think that you're getting an error because you haven't set a get method for the name variable in the objQuestion class. Try this:
Hi,
try this
public class repeatCon {
public class objQuestion{
public string Name;
public string SearchLabel;
public objQuestion(string N,string S){
Name = N;
SearchLabel = S;
}
}
public list<objQuestion> listquestions {get; set;}
public repeatcon(){
listquestions = new list<objQuestion>();
listquestions.add(new objQuestion('a','a');
listquestions.add(new objQuestion('b','b');
}
}
If this post solves your problem kindly mark it as solution. if this post is helpful please throw Kudos.
Thanks
This solves it. Thank you so much.