I am not sure how to word the question; I apologize if the title is not relevant to my problem.
Please pretend the following three classes are inner classes in a controller.
I have a base class with the following characteristics:
abstract class Form {
public List<Object> objects {get; set;}
public virtual List<Object> fetchObjects() {};
}
Here is the wrapper class for an sObject:
class Program {
public Program__c program {get; set;}
public Program(Program__c program) { this.program = program; }
}
Here is a class that extends the base class
class ProgramForm extends Form {
public ProgramForm() { objects = fetchObjects(); }
public override List<Object> fetchObjects() {
List<Program> programs = new List<Program>();
for (Program__c p : [select id, name from Program__c]) {
programs.add(new Program(p));
}
return programs;
}
}
Now, in the visual force,
<apex:dataTable value="{!programForm.objects}" var="program">
<apex:column> {!program.program['name']} </apex:column>
</apex:dataTable>
throws the following error: Unknown property 'Object.program'
If I remove List<Object> objects
member and List<Object> fetchObjects
method from the abstract Form class and insert a List<Program>
member and List<Program> fetchObjects
method in the extended ProgramForm class, I get the desired functionality. This is what I have done but I would rather not for obvious reasons.
How can I tell the visualforce to ignore the datatype and assume it has the appropriate members?
Thank you!