0
public with sharing class wrapper_test_controller 
{
    public list<sched> schedules{get;set;}

     public wrapper_test_controller(ApexPages.StandardController controller)
     {
        schedules = new List<sched>();

        list<teacher> object1 = [select id,name, First_name__c, Subject__c, Room_assignment__c from teacher__c ];

        list<time> object2 = [Select id, name, teacher__c, time__c, student__c, parent__c from schedule__c ];

        for(teacher__c teacher : object1)
        {
            schedules.add(new sched(teacher));
        }

        for (schedule__c oras: object2)
        {
            schedules.add(new shed(oras));
        }
    }

    public class sched
    {
        public Id id {get;set;}
        public Name name {get;set;}
        public string teacher{get;set;}
        public string tlname{get;set}    //  <--- line 24 in the original post
        public string tfname{get;set}
        public string parent{get;set}
        public string student{get;set}
        public string time{get;set}
        public string room{get;set}
        public string subject{get;set}

        public sched(teacher__c object1)
        {
            this.id = object1.id;
            this.tlname = object1.name;
            this.tfname = object1.tfname;
            this.subject = object1.subject;
            this.room = object1.room;
        }

        public sched(schedule__c object2)
        {
            this.id = object2.id;
            this.name = object2.schedname;
            this.teacher = object2.teacher;
            this.time = object2.time;
            this.student =object2.student;
            this.parent =object2.parent;
        }
    }
}

1 Answer 1

2

The error is in fact in line 24, after set, there should be a semi-colon:

public string tlname{get;set} should be public string tlname{get;set;}

All properties of that class after line 24 have that issue as well, it should be:

public string tlname{get;set;}
public string tfname{get;set;}
public string parent{get;set;}
public string student{get;set;}
public string time{get;set;}
public string room{get;set;}
public string subject{get;set;}

Also, I noticed in your code that you are querying for a lot of fields that you don't reference in you wrapper class constructor:

list<teacher> object1 = [select id,name, First_name__c, Subject__c, Room_assignment__c from teacher__c ];

later..

public sched(teacher__c object1)
{
    this.id = object1.id;
    this.tlname = object1.name;
    this.tfname = object1.tfname;
    this.subject = object1.subject;
    this.room = object1.room;
}

you probably wanted this constructor to be something like this:

public sched(teacher__c object1)
{
    this.id = object1.id;
    this.tlname = object1.name;
    this.tfname = object1.First_name__c;
    this.subject = object1.Subject__c;
    this.room = object1.Room_assignment__c;
}

similarly for the other constructor:

    public sched(schedule__c object2)
    {
        this.id = object2.id;
        this.name = object2.name;
        this.teacher = object2.teacher__c;
        this.time = object2.time__c;
        this.student =object2.student__c;
        this.parent =object2.parent__c;
    }

Also, the variable object2 should be of type list<schedule__c>:

list<schedule__c> object2 = [Select id, name, teacher__c, time__c, student__c, parent__c from schedule__c ];

and likewise for object1:

list<teacher__c> object1 = [select id,name, First_name__c, Subject__c, Room_assignment__c from teacher__c ];
1
  • 1
    no problem. I hope I was able to help.
    – martin
    Feb 11, 2016 at 2:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .