+ Start a Discussion
Linked2MarkLinked2Mark 

Wrapper class not visible

I have a VF page that is not working properly and I cant figure out why. Page and controller are shown below. The page wont build as I am getting the following error.

Error:(1, 1) Unknown property 'TasksHomePageController.eAllTasks.taskSubject'

It looks like the page cant see the fields in the wrapper class. Cant figure out why that is happening. Any tips?

<apex:page id="TasksHomePage" Controller="TasksHomePageController">
    <apex:stylesheet value="/resource/SLDS0102/assets/styles/salesforce-lightning-design-system-ltng.css"/>
    <apex:pageBlock title="Unresolved Emails">
        <apex:outputText value="There are {0} incomplete Tasks." >
            <apex:param value="{!allTasksSize}"/>
        </apex:outputText>
        <br></br>            <br></br>

        <apex:pageBlockTable value="{!allTasks}" var="myTask">

            <apex:column value="{!myTask.taskSubject}"/>
            <apex:column value="{!myTask.taskStatus}"/>
            <apex:column value="{!myTask.TaskType}"/>
            <apex:column value="{!myTask.TaskActivityDate}"/>
            <apex:column value="{!myTask.TaskAccount}"/>
        </apex:pageBlockTable>


    </apex:pageBlock>
</apex:page>
 
public with sharing class TasksHomePageController {
    public List<Task>       allTasks {get; set;}
    public List<eAllTasks>  eAT {get; set;}
    public Integer          allTasksSize  {get; set;}

    public TasksHomePageController() {
        Id usrid = UserInfo.getUserId() ;
        allTasks = [Select Id, Subject, WhoId, WhatId,  ownerId, status, type, activityDate, CreatedDate FROM Task
            Where OwnerId = :usrId and status!= 'Completed'];
        allTasksSize = allTasks.size();
        system.debug('allTasks.size() is ==> ' + allTasks.size());

        for(Task t :allTasks){
            eAllTasks e                     = new eAllTasks();
            e.taskSubject                   = t.Subject;
            e.TaskId                        = t.Id;
            e.taskWhoId                     = t.WhoId;
            e.taskWhatId                    = t.WhatId;
            e.taskOwnerId                   = t.OwnerId;
            e.taskStatus                    = t.Status;
            e.taskActivityDate              = t.ActivityDate;
            e.taskType                      = t.Type;
            e.taskWhoIdType                 = String.ValueOf(t.WhoId).substring(0,3);

            system.debug(' e is ==> ' + e);
            eAT.add(e);
            system.debug('eAT.size() is ==> ' + eAT.Size());
        }

        List<Id>        contactIDsInTasks       = new List<Id>();
        List<Id>        leadIDsInTasks          = new List<Id>();

        // WhoId that starts with 'oo3' is a Contact
        // WhoId that starts with '00Q is a Lead
        if(eAT.size() > 0){
            for(eAllTasks e :eAT){
                if(e.taskWhoIdType ==  '003'){
                    contactIDsInTasks.add(e.taskWhoId);
                } else if(e.taskWhoIdType == '00Q'){
                    leadIDsInTasks.add(e.taskWhoId);
                }
            }
        }
        List<Contact>   contactsInTasks = new List<Contact>();
        List<Lead>      leadsInTasks    = new List<Lead>();

        If(contactsInTasks.size() > 0){
            contactsInTasks = [SELECT Id, Account.Name FROM Contact WHERE ID IN :contactIDsInTasks];
        }
        if(leadIDsInTasks.size() > 0){
            leadsInTasks = [SELECT ID, Company FROM Lead WHERE ID IN :leadIDsInTasks];
        }
        //Create the maps here - map the eAT to the COntact or Lead
        Map<Id, Contact> contactMap = new Map<id, Contact>();
        Map<Id, Lead>   leadMap     = new Map<id, Lead>();
        if(contactsInTasks.size() > 0){
            for(Contact c :contactsInTasks){
                contactMap.put(c.Id, c);
            }
        }
        If(leadsInTasks.size() > 0){
            for(Lead l :leadsInTasks){
                leadMap.put(l.id, l);
            }
        }

         // everything is ready - now Get the Account Name from either the Contact or Lead

        if(eAT.size() > 0){
            for(eAllTasks e :eAT){
                if(contactMap.get(e.TaskWhoId) != null){
                    e.taskAccount = contactMap.get(e.TaskWhoId).Account.Name;
                } else if(leadMap.get(e.TaskWhoId) != null){
                    e.taskAccount = leadMap.get(e.TaskWhoId).Company;
                }
            }
        }
    }
    public class eAllTasks{

            string      taskSubject;
            Id          TaskId;
            Id          taskWhoId;
            Id          taskWhatId;
            id          taskOwnerId;
            string      taskStatus;
            date        taskActivityDate;
            string      taskAccount;
            string      taskWhoIdType;
            string      taskType;
    }
Steven NsubugaSteven Nsubuga
Use public properties as the definitions in the inner eAllTasks class.
public with sharing class TasksHomePageController {
    public List<Task>       allTasks {get; set;}
    public List<eAllTasks>  eAT {get; set;}
    public Integer          allTasksSize  {get; set;}

    public TasksHomePageController() {
        Id usrid = UserInfo.getUserId() ;
        allTasks = [Select Id, Subject, WhoId, WhatId,  ownerId, status, type, activityDate, CreatedDate FROM Task
            Where OwnerId = :usrId and status!= 'Completed'];
        allTasksSize = allTasks.size();
        system.debug('allTasks.size() is ==> ' + allTasks.size());

        for(Task t :allTasks){
            eAllTasks e                     = new eAllTasks();
            e.taskSubject                   = t.Subject;
            e.TaskId                        = t.Id;
            e.taskWhoId                     = t.WhoId;
            e.taskWhatId                    = t.WhatId;
            e.taskOwnerId                   = t.OwnerId;
            e.taskStatus                    = t.Status;
            e.taskActivityDate              = t.ActivityDate;
            e.taskType                      = t.Type;
            e.taskWhoIdType                 = String.ValueOf(t.WhoId).substring(0,3);

            system.debug(' e is ==> ' + e);
            eAT.add(e);
            system.debug('eAT.size() is ==> ' + eAT.Size());
        }

        List<Id>        contactIDsInTasks       = new List<Id>();
        List<Id>        leadIDsInTasks          = new List<Id>();

        // WhoId that starts with 'oo3' is a Contact
        // WhoId that starts with '00Q is a Lead
        if(eAT.size() > 0){
            for(eAllTasks e :eAT){
                if(e.taskWhoIdType ==  '003'){
                    contactIDsInTasks.add(e.taskWhoId);
                } else if(e.taskWhoIdType == '00Q'){
                    leadIDsInTasks.add(e.taskWhoId);
                }
            }
        }
        List<Contact>   contactsInTasks = new List<Contact>();
        List<Lead>      leadsInTasks    = new List<Lead>();

        If(contactsInTasks.size() > 0){
            contactsInTasks = [SELECT Id, Account.Name FROM Contact WHERE ID IN :contactIDsInTasks];
        }
        if(leadIDsInTasks.size() > 0){
            leadsInTasks = [SELECT ID, Company FROM Lead WHERE ID IN :leadIDsInTasks];
        }
        //Create the maps here - map the eAT to the COntact or Lead
        Map<Id, Contact> contactMap = new Map<id, Contact>();
        Map<Id, Lead>   leadMap     = new Map<id, Lead>();
        if(contactsInTasks.size() > 0){
            for(Contact c :contactsInTasks){
                contactMap.put(c.Id, c);
            }
        }
        If(leadsInTasks.size() > 0){
            for(Lead l :leadsInTasks){
                leadMap.put(l.id, l);
            }
        }

         // everything is ready - now Get the Account Name from either the Contact or Lead

        if(eAT.size() > 0){
            for(eAllTasks e :eAT){
                if(contactMap.get(e.TaskWhoId) != null){
                    e.taskAccount = contactMap.get(e.TaskWhoId).Account.Name;
                } else if(leadMap.get(e.TaskWhoId) != null){
                    e.taskAccount = leadMap.get(e.TaskWhoId).Company;
                }
            }
        }
    }
    public class eAllTasks{

            public string      taskSubject {get; set;}
            public Id          TaskId {get; set;}
            public Id          taskWhoId {get; set;}
            public Id          taskWhatId {get; set;}
            public id          taskOwnerId {get; set;}
            public string      taskStatus {get; set;}
            public date        taskActivityDate {get; set;}
            public string      taskAccount {get; set;}
            public string      taskWhoIdType {get; set;}
            public string      taskType {get; set;}
    }
}
Raj VakatiRaj Vakati
You need to use Get and set if you wanted to access them visualforce page .. (MVC pattern )